From c9c3b33704fe7cc50cca997045a067c7c38b017b Mon Sep 17 00:00:00 2001 From: Vivek Gaddam <154349504+VivekGaddam@users.noreply.github.com> Date: Wed, 22 Oct 2025 19:45:04 +0530 Subject: [PATCH] Word to pdf (#88) * feat(pdf-tools): add sanitize-pdf tool for comprehensive document cleaning Implement a new PDF sanitization tool that allows users to remove various potentially sensitive elements from PDFs including metadata, annotations, JavaScript, embedded files, and more. The tool provides configurable options through checkboxes to selectively remove different types of content while preserving the core document structure. Extract reusable utility functions from existing tools (remove-metadata, remove-annotations, flatten) to support the new sanitization feature. The tool handles edge cases gracefully and provides feedback when no changes are made. * fix(sanitize-pdf): remove javascript actions, external links and font files - Remove JavaScript actions from annotations and form fields - Remove external links (URI, Launch, GoTo) from annotations - Remove embedded font files while preserving font descriptors - Add detailed error logging for each operation * fix(sanitize-pdf): improve link removal and add named destinations cleanup - Refactor link annotation removal logic to handle more action types (URI, Launch, GoTo, GoToR) - Add cleanup of named destinations in catalog and names dictionary - Improve error handling and logging throughout the sanitization process * chore: update config files, icons and readme - Update FUNDING.yml formatting - Remove debug log in sanitize-pdf.ts - Adjust test expectation for tool count - Standardize dependabot.yml quotes - Update tool icons in config - Expand and reorganize README features list - Fix markdown formatting in README * Release v1.1.0 * without confilt --------- Co-authored-by: abdullahalam123 --- .github/FUNDING.yml | 2 +- .github/dependabot.yml | 14 +- README.md | 34 +- index.html | 22 + package.json | 2 +- src/js/config/pdf-tools.ts | 1 + src/js/config/tools.ts | 17 +- src/js/handlers/fileHandler.ts | 6 +- src/js/logic/flatten.ts | 8 +- src/js/logic/index.ts | 6 +- src/js/logic/remove-annotations.ts | 71 +- src/js/logic/remove-metadata.ts | 57 +- src/js/logic/sanitize-pdf.ts | 587 +++++++++++++++ src/js/logic/word-to-pdf.ts | 243 +++--- src/js/ui.ts | 102 ++- src/lib/zetajs/office_thread.js | 83 +++ src/lib/zetajs/zeta.js | 1104 ++++++++++++++++++++++++++++ src/lib/zetajs/zetaHelper.js | 209 ++++++ src/tests/pdf-tools.test.ts | 2 +- src/types/globals.d.ts | 8 + vite.config.ts | 8 +- 21 files changed, 2371 insertions(+), 215 deletions(-) create mode 100644 src/js/logic/sanitize-pdf.ts create mode 100644 src/lib/zetajs/office_thread.js create mode 100644 src/lib/zetajs/zeta.js create mode 100644 src/lib/zetajs/zetaHelper.js diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index f11c435f..5aba4924 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: alam00000 -ko_fi: alio01 \ No newline at end of file +ko_fi: alio01 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8bf2edc7..b7f273d2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,15 +1,15 @@ version: 2 updates: - - package-ecosystem: "npm" - directory: "/" + - package-ecosystem: 'npm' + directory: '/' schedule: - interval: "daily" + interval: 'daily' groups: npm-dependencies: patterns: - - "*" + - '*' - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: - interval: "daily" + interval: 'daily' diff --git a/README.md b/README.md index 4bd04a99..52fe5c60 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,18 @@ BentoPDF offers a comprehensive suite of tools to handle all your PDF needs. ### Organize & Manage PDFs -| Tool Name | Description | -| :----------------- | :------------------------------------------------------------------------- | -| **Merge PDFs** | Combine multiple PDF files into one. | -| **Split PDFs** | Extract specific pages or divide a document into smaller files. | -| **Organize Pages** | Reorder, duplicate, or delete pages with a simple drag-and-drop interface. | -| **Extract Pages** | Save a specific range of pages as a new PDF. | -| **Delete Pages** | Remove unwanted pages from your document. | -| **Rotate PDF** | Rotate individual or all pages in a document. | -| **N-Up PDF** | Combine multiple pages onto a single page. | -| **View PDF** | A powerful, integrated PDF viewer. | +| Tool Name | Description | +| :------------------------ | :------------------------------------------------------------------------- | +| **Merge PDFs** | Combine multiple PDF files into one. | +| **Split PDFs** | Extract specific pages or divide a document into smaller files. | +| **Organize Pages** | Reorder, duplicate, or delete pages with a simple drag-and-drop interface. | +| **Extract Pages** | Save a specific range of pages as a new PDF. | +| **Delete Pages** | Remove unwanted pages from your document. | +| **Rotate PDF** | Rotate individual or all pages in a document. | +| **N-Up PDF** | Combine multiple pages onto a single page. | +| **View PDF** | A powerful, integrated PDF viewer. | +| **Alternate & Mix pages** | Merge pages by alternating pages from each PDF. | +| **Posterize PDF** | Split a PDF into multiple smaller pages for print. | ### Edit & Modify PDFs @@ -52,6 +54,7 @@ BentoPDF offers a comprehensive suite of tools to handle all your PDF needs. | **Fill Forms** | Fill out PDF forms directly in your browser. | | **Flatten PDF** | Flatten form fields and annotations into static content. | | **Remove Annotations** | Remove comments, highlights, and other annotations. | +| **Remove Blank Pages** | Auto detect and remove blank pages in a PDF. | ### Convert to PDF @@ -82,6 +85,8 @@ BentoPDF offers a comprehensive suite of tools to handle all your PDF needs. | **Redact Content** | Permanently remove sensitive content from your PDFs. | | **Edit Metadata** | View and modify PDF metadata (author, title, keywords, etc.). | | **Remove Metadata** | Strip all metadata from your PDF for privacy. | +| **Linearize PDF** | Optimize PDF for fast web view. | +| **Sanitize PDF** | Remove potentially unwanted or malicous files from PDF. | --- @@ -165,8 +170,8 @@ npm run release:minor npm run release:major ``` -```` For detailed release instructions, see [RELEASE.md](RELEASE.md). + ### 🚀 Development Setup #### Option 1: Run with npm @@ -176,7 +181,7 @@ For detailed release instructions, see [RELEASE.md](RELEASE.md). ```bash git clone https://github.com/alam00000/bentopdf.git cd bentopdf -```` + ``` 2. **Install Dependencies**: @@ -235,10 +240,8 @@ BentoPDF was originally built using **HTML**, **CSS**, and **vanilla JavaScript* - **HTML to PDF**: Convert HTML files or web pages into PDF documents. - **Markdown to PDF**: Enhanced support for converting `.md` files to PDF. -- **Sanitize PDF**: Remove potentially malicious content like scripts from PDFs. - **Convert to PDF/A**: Convert PDFs to the PDF/A archival format. - **Edit PDF Content**: Directly edit text and other content within your PDF. -- **Linearize PDF**: Optimize PDFs for fast web viewing. - **PDF to Office**: Converts PDF files into editable Word, Excel, and PowerPoint formats. - **Office to PDF**: Converts Word, Excel, and PowerPoint documents into optimized PDFs. @@ -266,10 +269,11 @@ BentoPDF wouldn't be possible without the amazing open-source tools and librarie - **[PDFLib.js](https://pdf-lib.js.org/)** – For enabling powerful client-side PDF manipulation. - **[PDF.js](https://mozilla.github.io/pdf.js/)** – For the robust PDF rendering engine in the browser. - **[PDFKit](https://pdfkit.org/)** – For creating and editing PDFs with ease. -- **[EmbedPDF](https://github.com/embedpdf/embed-pdf-viewer)** – For seamless PDF embedding in web pages. +- **[EmbedPDF](https://github.com/embedpdf/embed-pdf-viewer)** – For seamless PDF editing in pure JS. - **[Cropper.js](https://fengyuanchen.github.io/cropperjs/)** – For intuitive image cropping functionality. - **[Vite](https://vitejs.dev/)** – For lightning-fast development and build tooling. - **[Tailwind CSS](https://tailwindcss.com/)** – For rapid, flexible, and beautiful UI styling. +- **[qpdf](https://github.com/qpdf/qpdf)** and **[qpdf-wasm](https://github.com/neslinesli93/qpdf-wasm)**– A powerful command-line tool and library for inspecting, repairing, and transforming PDF file ported to wasm Your work inspires and empowers developers everywhere. Thank you for making open-source amazing! diff --git a/index.html b/index.html index 6ade8a4e..767cd74f 100644 --- a/index.html +++ b/index.html @@ -31,6 +31,7 @@ +