feat(pdf): add extract text, page numbers, crop, extract images operations

Adds four new PDFOperations: pdfExtractText (pdfjs-dist getTextContent),
pdfAddPageNumbers (reuses pdfWatermark's position-mapping logic, extracted
into a shared resolvePosition helper), pdfCrop (page.setCropBox against the
existing MediaBox), and pdfExtractImages (pdfjs-dist operator list +
paintImageXObject + sharp). Wired into executeOperation's switch and the PDF
editor dialog UI (4 new sections/toolbar buttons/menu items) with no new IPC
channel needed.

pdfjs-dist v5 is ESM-only, so it's loaded via dynamic import() of its
Node-friendly legacy build; Jest needs --experimental-vm-modules to support
that, so the test scripts now set NODE_OPTIONS accordingly via cross-env.

Amit Haridas
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent abcfb03e52
commit 2334ab30ed
6 changed files with 867 additions and 46 deletions
+3 -3
View File
@@ -5,9 +5,9 @@
"main": "src/main.js",
"scripts": {
"start": "electron .",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch",
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"lint": "eslint src tests",
"lint:fix": "eslint src tests --fix",
"format": "prettier --write src tests",