mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-22 15:39:31 +02:00
init new pdf to png
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { tool as pdfPdfToPng } from './pdf-to-png/meta';
|
||||
import { tool as pdfRotatePdf } from './rotate-pdf/meta';
|
||||
import { meta as splitPdfMeta } from './split-pdf/meta';
|
||||
import { meta as mergePdf } from './merge-pdf/meta';
|
||||
@@ -12,5 +13,6 @@ export const pdfTools: DefinedTool[] = [
|
||||
compressPdfTool,
|
||||
protectPdfTool,
|
||||
mergePdf,
|
||||
pdfToEpub
|
||||
pdfToEpub,
|
||||
pdfPdfToPng
|
||||
];
|
||||
|
62
src/pages/tools/pdf/pdf-to-png/index.tsx
Normal file
62
src/pages/tools/pdf/pdf-to-png/index.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Box } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
import ToolContent from '@components/ToolContent';
|
||||
import { ToolComponentProps } from '@tools/defineTool';
|
||||
import ToolTextInput from '@components/input/ToolTextInput';
|
||||
import ToolTextResult from '@components/result/ToolTextResult';
|
||||
import { GetGroupsType } from '@components/options/ToolOptions';
|
||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||
import { main } from './service';
|
||||
import { InitialValuesType } from './types';
|
||||
|
||||
const initialValues: InitialValuesType = {
|
||||
// splitSeparator: '\n'
|
||||
};
|
||||
|
||||
const exampleCards: CardExampleType<InitialValuesType>[] = [
|
||||
{
|
||||
title: 'Split a String',
|
||||
description: 'This example shows how to split a string into multiple lines',
|
||||
sampleText: 'Hello World,Hello World',
|
||||
sampleResult: `Hello World
|
||||
Hello World`,
|
||||
sampleOptions: {
|
||||
// splitSeparator: ','
|
||||
}
|
||||
}
|
||||
];
|
||||
export default function PdfToPng({
|
||||
title,
|
||||
longDescription
|
||||
}: ToolComponentProps) {
|
||||
const [input, setInput] = useState<string>('');
|
||||
const [result, setResult] = useState<string>('');
|
||||
|
||||
const compute = (values: InitialValuesType, input: string) => {
|
||||
setResult(main(input, values));
|
||||
};
|
||||
|
||||
const getGroups: GetGroupsType<InitialValuesType> | null = ({
|
||||
values,
|
||||
updateField
|
||||
}) => [
|
||||
{
|
||||
title: 'Example Settings',
|
||||
component: <Box></Box>
|
||||
}
|
||||
];
|
||||
return (
|
||||
<ToolContent
|
||||
title={title}
|
||||
input={input}
|
||||
inputComponent={<ToolTextInput value={input} onChange={setInput} />}
|
||||
resultComponent={<ToolTextResult value={result} />}
|
||||
initialValues={initialValues}
|
||||
exampleCards={exampleCards}
|
||||
getGroups={getGroups}
|
||||
setInput={setInput}
|
||||
compute={compute}
|
||||
toolInfo={{ title: `What is a ${title}?`, description: longDescription }}
|
||||
/>
|
||||
);
|
||||
}
|
14
src/pages/tools/pdf/pdf-to-png/meta.ts
Normal file
14
src/pages/tools/pdf/pdf-to-png/meta.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { defineTool } from '@tools/defineTool';
|
||||
import { lazy } from 'react';
|
||||
|
||||
export const tool = defineTool('pdf', {
|
||||
name: 'PDF to PNG',
|
||||
path: 'pdf-to-png',
|
||||
icon: 'mdi:image-multiple', // Iconify icon ID
|
||||
description: 'Transform PDF documents into PNG panels.',
|
||||
shortDescription: 'Convert PDF into PNG images',
|
||||
keywords: ['pdf', 'png', 'convert', 'image', 'extract', 'pages'],
|
||||
longDescription:
|
||||
'Upload a PDF and convert each page into a high-quality PNG image directly in your browser. This tool is ideal for extracting visual content or sharing individual pages. No data is uploaded — everything runs locally.',
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
@@ -0,0 +1,6 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
// import { main } from './service';
|
||||
//
|
||||
// describe('pdf-to-png', () => {
|
||||
//
|
||||
// })
|
5
src/pages/tools/pdf/pdf-to-png/service.ts
Normal file
5
src/pages/tools/pdf/pdf-to-png/service.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { InitialValuesType } from './types';
|
||||
|
||||
export function main(input: string, options: InitialValuesType): string {
|
||||
return input;
|
||||
}
|
3
src/pages/tools/pdf/pdf-to-png/types.ts
Normal file
3
src/pages/tools/pdf/pdf-to-png/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type InitialValuesType = {
|
||||
// splitSeparator: string;
|
||||
};
|
Reference in New Issue
Block a user