From 09cdae2e5f85808cf3bfb56a0b0fe68383fe0292 Mon Sep 17 00:00:00 2001 From: Ozkan Selcuk <82905592+EienMosu@users.noreply.github.com> Date: Mon, 5 Oct 2026 01:44:14 +0300 Subject: [PATCH] pdf-import: pass the pdf.js worker as a file:// URL (fixes `jdf convert x.pdf` on Windows) pdf.js runs its fake worker on Node by import()ing GlobalWorkerOptions.workerSrc. We set it to the resolved absolute path, which Node's ESM loader rejects on Windows ("Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'd:'"), so every PDF conversion in the CLI fails there, including the published @uurtech/jdf-cli bundle. pathToFileURL() gives a file:// URL on every platform. On macOS the output of spec/examples/sample.pdf is byte-identical before and after (same sha256), and verify:regress (25 checked, 0 changed), verify:tables (120/120) and verify:order (100%) stay green. The same fix was part of the win branch (ed4622f) and was reverted in 2572af0 only to keep that PR scoped to the desktop app. Co-authored-by: rcpzen --- packages/jdf-pdf-import/src/node.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/jdf-pdf-import/src/node.ts b/packages/jdf-pdf-import/src/node.ts index b60c315..6a7d55c 100644 --- a/packages/jdf-pdf-import/src/node.ts +++ b/packages/jdf-pdf-import/src/node.ts @@ -43,7 +43,11 @@ async function loadNodePdfJs() { } const workerPath = require_.resolve("pdfjs-dist/build/pdf.worker.mjs"); if (lib.GlobalWorkerOptions) { - lib.GlobalWorkerOptions.workerSrc = workerPath; + // The fake worker `import()`s this string. Node's ESM loader rejects + // bare absolute paths on Windows ("Received protocol 'd:'"), so hand + // it a proper file:// URL on every platform. + const { pathToFileURL } = await import("node:url"); + lib.GlobalWorkerOptions.workerSrc = pathToFileURL(workerPath).href; } // Sibling asset directories shipped in the pdfjs-dist package. const { dirname, join } = await import("node:path");