Skip to content

Commit 1f31b47

Browse files
committed
Fixed loader path for Windows
1 parent d45cc24 commit 1f31b47

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Electron/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { screen, globalShortcut} = require('electron/main')
55

66
const pdfjsLib = require("./pdfjs/pdf.mjs");
77

8+
const { pathToFileURL } = require("url")
89

910
const path = require('path')
1011
const { platform } = require('node:process');
@@ -143,8 +144,12 @@ async function cropPdfBuffer(inputBuffer, margin = 10, pageNumber = 1) {
143144
//const pdfjsLib = require("./pdfjs/pdf");
144145
//const pdfjsLib = {};
145146

147+
148+
146149
async function getVisualBoundingBox(pdfBuffer, pageNumber = 1, scale = 2.0) {
147-
pdfjsLib.GlobalWorkerOptions.workerSrc = require.resolve('./pdfjs/pdf.worker.mjs');
150+
pdfjsLib.GlobalWorkerOptions.workerSrc = pathToFileURL(
151+
path.join(__dirname, "pdfjs", "pdf.worker.mjs")
152+
).href;
148153
const loadingTask = pdfjsLib.getDocument({ data: pdfBuffer });
149154
const pdf = await loadingTask.promise;
150155

0 commit comments

Comments
 (0)