init new pdf to png

This commit is contained in:
omenmn
2025-06-21 14:18:15 +05:30
parent d25f7ca557
commit a262c9834f
6 changed files with 93 additions and 1 deletions

View File

@@ -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
];

View 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 }}
/>
);
}

View 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'))
});

View File

@@ -0,0 +1,6 @@
import { expect, describe, it } from 'vitest';
// import { main } from './service';
//
// describe('pdf-to-png', () => {
//
// })

View File

@@ -0,0 +1,5 @@
import { InitialValuesType } from './types';
export function main(input: string, options: InitialValuesType): string {
return input;
}

View File

@@ -0,0 +1,3 @@
export type InitialValuesType = {
// splitSeparator: string;
};