TypeError: Cannot read properties of undefined (reading 'Mode')

Which product are you using?
PDF.js Express Plus

PDF.js Express Version
@pdftron/pdfjs-express”: “^7.3.9”,

Detailed description of issue
I am receiving the error message TypeError: Cannot read properties of undefined (reading ‘Mode’) when trying to set the following const for docViewer.textSearchInit
const { docViewer, Annotations, CoreControls } = instance;

const searchMode = CoreControls.Search.Mode.PAGE_STOP | CoreControls.Search.Mode.HIGHLIGHT;

Additionally, the code snippet above is from your samples.

Expected behaviour
I expect that the properties are found.

Does your issue happen with every document, or just one?
Every document

Link to document
I cannot because it contains sensitive information and I don’t think it’s relevant
Code snippet
const { docViewer, Annotations, CoreControls } = instance;

const searchMode = CoreControls.Search.Mode.PAGE_STOP | CoreControls.Search.Mode.HIGHLIGHT;

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

Hello dcheli,

Welcome to the PDFJS Express forum!

You can access the search modes with the latest version by doing:

instance.Core.Search.Mode.PAGE_STOP

Which sample has this code snippet?
Let me know if this works for you

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

This is the documentation that contains the code snippet.
Advanced Search | Documentation (pdfjs.express)

Hello dcheli,

Thank you for sending this, it looks like this guide is for version 8.0+ with the new namespace changes.

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

Hey Tyler,
If you change the version on the page to 7.x.x you will see what I’m referring to (see below). I am using 7.3.9

const searchMode = CoreControls.Search.Mode.PAGE_STOP | CoreControls.Search.Mode.HIGHLIGHT;;

Hello dcheli,

My apologies, completely forgot to switch the version.

I wasnt able to get the error to occur with that whole snippet. Can you try with the latest build of v7.3.9?
Performing npm install @pdftron/pdfjs-express@7.3.9 should get the latest build.

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here