feat: pdf editor

This commit is contained in:
Ibrahima G. Coulibaly
2025-07-09 17:51:12 +01:00
parent 143a5684cf
commit cd19ffccf6
4 changed files with 103 additions and 18 deletions

View File

@@ -0,0 +1,59 @@
import React, { useState } from 'react';
import { Box } from '@mui/material';
import ToolPdfInput from '@components/input/ToolPdfInput';
import ToolContent from '@components/ToolContent';
import { ToolComponentProps } from '@tools/defineTool';
import { EmbedPDF } from '@simplepdf/react-embed-pdf';
export default function PdfEditor({ title }: ToolComponentProps) {
const [input, setInput] = useState<File | null>(null);
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
const onFileChange = (file: File | null) => {
if (file) {
setInput(file);
const url = URL.createObjectURL(file);
setPdfUrl(url);
} else {
setInput(null);
setPdfUrl(null);
}
};
return (
<ToolContent
title={title}
initialValues={{}}
getGroups={null}
input={input}
inputComponent={
<>
{pdfUrl ? (
<Box sx={{ width: '100%', height: '80vh' }}>
<EmbedPDF
mode="inline"
style={{ width: '100%', height: '100%' }}
documentURL={pdfUrl}
/>
</Box>
) : (
<ToolPdfInput
value={input}
onChange={onFileChange}
accept={['application/pdf']}
title="Upload a PDF to edit"
/>
)}
</>
}
toolInfo={{
title: 'PDF Editor',
description:
'Edit, annotate, highlight, fill forms, and export your PDFs entirely in the browser. Add text, drawings, signatures, and more to your PDF documents with this powerful online editor.'
}}
compute={() => {
/* no background compute required */
}}
/>
);
}

View File

@@ -0,0 +1,27 @@
import { defineTool } from '@tools/defineTool';
import { lazy } from 'react';
export const tool = defineTool('pdf', {
name: 'PDF Editor',
path: 'editor',
icon: 'mdi:file-document-edit',
description:
'Advanced PDF editor with annotation, form-fill, highlight, and export capabilities. Edit your PDFs directly in the browser with professional-grade tools including text insertion, drawing, highlighting, signing and form filling.',
shortDescription: 'Edit PDFs with advanced annotation and editing tools',
keywords: [
'pdf',
'editor',
'edit',
'annotate',
'highlight',
'form',
'fill',
'text',
'drawing',
'signature',
'export',
'annotation',
'markup'
],
component: lazy(() => import('./index'))
});

View File

@@ -9,12 +9,12 @@ import { meta as pdfToEpub } from './pdf-to-epub/meta';
import { tool as pdfEditor } from './editor/meta';
export const pdfTools: DefinedTool[] = [
pdfEditor,
splitPdfMeta,
pdfRotatePdf,
compressPdfTool,
protectPdfTool,
mergePdf,
pdfToEpub,
pdfPdfToPng,
pdfEditor
pdfPdfToPng
];