Skip to content

Improve pdfjs support #30655

@sigmaSd

Description

@sigmaSd

Currently for pdfjs to work you need this

import DOMMatrix from "npm:@thednp/dommatrix@2.0.12";
globalThis.DOMMatrix = DOMMatrix;
globalThis.process = undefined;
Object.defineProperty(navigator, "platform", {
  value: "Linux",
});
const pdfjsLib = await import("npm:pdfjs-dist@5.4.149");
pdfjsLib.GlobalWorkerOptions.workerSrc = import.meta.resolve("npm:pdfjs-dist@5.4.149/build/pdf.worker.mjs");

Depends on:

What other improvements:

  • currently you need to hide process global, I guess this can be improved upstream by detecting deno correctly
  • would be great if deno detected the worker automatically
  • it shows a warning about using fake worker, maybe there is a way to make it work with normal web workers since deno does support it

Note: The node legacy branch obviously works but it requires ffi (for npm canvas) while this one require no permission

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions