Using pdf.js in a plugin?

70 views
Skip to first unread message

Alain Borel

unread,
Aug 2, 2025, 10:07:31 AMAug 2
to zotero-dev
Dear all,

I'm interested in using pdf.js in a Zotero plugin, and thanks to zotero-dev I have found one other plugin whose developer had the same requirement: https://github.com/FrankRCastillo/zotero-books-to-sections . That plugin loads pdf.js in the startup function as follows:

Services.scriptloader.loadSubScript('resource://pdf.js/build/pdf.js', this);

Unfortunately, this is broken in the v8 beta in the context of the switch to Firefox 140 and .jsm (as announced recently https://www.zotero.org/support/dev/zotero_8_for_developers#zotero_8_for_developers ).

My naive understanding is that I should be able to import the module like this (either in the startup function or somewhere in my main source file):

const { pdfjsLib } = ChromeUtils.importESModule("resource://zotero/reader/pdf/build/pdf.mjs")

Unfortunately this fails with this error:

 can't redefine non-configurable property "reduce"

Any thoughts/suggestions? I'd be happy to read those.

Cheers,
A. Borel

Alain Borel

unread,
Aug 3, 2025, 4:38:24 AMAug 3
to zotero-dev
Should I use await import('resource://zotero/reader/pdf/build/pdf.mjs') instead? It seem to work in the console but in my code it causes an error:
Error: No ScriptLoader found for the current context

As always, any input is welcome.
A. Borel

volatile static

unread,
Aug 18, 2025, 9:45:41 AMAug 18
to zotero-dev
Reply all
Reply to author
Forward
0 new messages