diff --git a/public/locales/en/pdf.json b/public/locales/en/pdf.json index 52b8eb82..b602084b 100644 --- a/public/locales/en/pdf.json +++ b/public/locales/en/pdf.json @@ -41,7 +41,9 @@ "editor": { "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, signing and editing tools", - "title": "PDF Editor" + "title": "PDF Editor", + "upload": "Upload PDF", + "clear": "Clear Input" }, "formBuilder": { "title": "PDF Form Builder", diff --git a/src/pages/tools/pdf/editor/index.tsx b/src/pages/tools/pdf/editor/index.tsx index 29c2b034..8c04246a 100644 --- a/src/pages/tools/pdf/editor/index.tsx +++ b/src/pages/tools/pdf/editor/index.tsx @@ -1,29 +1,60 @@ -import React from 'react'; -import { Box } from '@mui/material'; -import ToolContent from '@components/ToolContent'; -import { ToolComponentProps } from '@tools/defineTool'; -import { EmbedPDF } from '@simplepdf/react-embed-pdf'; +import { useState, useEffect, useRef } from 'react'; +import { Box, Button } from '@mui/material'; +import { PDFViewer } from '@embedpdf/react-pdf-viewer'; +import { useTranslation } from 'react-i18next'; + +export default function PdfEditor() { + const { t } = useTranslation('pdf'); + const [src, setSrc] = useState(null); + const fileInputRef = useRef(null); + + const handleUpload = (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (file) setSrc(URL.createObjectURL(file)); + }; + + const handleClear = () => { + setSrc(null); + if (fileInputRef.current) fileInputRef.current.value = ''; + }; + + useEffect( + () => () => { + if (src) URL.revokeObjectURL(src); + }, + [src] + ); -export default function PdfEditor({ title }: ToolComponentProps) { return ( - - + + + + + + {src && ( + + - } - 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 */ - }} - /> + )} + ); }