enableElements is either gone or not?

I can see enableElements is valid here: https://www.pdftron.com/api/web/UI.html#.enableElements
but I get an error when I run it in my code:

enableElements is not a valid option name. See http://r.pdftron.com/api/options_anchor for all available options.

It was in a tutorial for modifying the UI somewhere which is how I found it.

Thanks

Craig

Hi there,

Thank you for your feedback.

I just want to clarify that pdf.js and PDFTron’s WebViewer are separate products. This is why documentation for PDFTron’s WebViewer may overlap but not necessary work, as there are much more features in PDFTron’s WebViewer.

The correct documentation you should use for pdf.js is available here:

This is the API page for enableElements:
https://pdfjs.express/api/UI.html#.enableElements

And this is the guide for enableElements:

Best regards,
Kevin Kim


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

1 Like

Hey Kim,

Thanks for the response. I’m only using PDF.js Express and the error message and link I refer to came from running against that library:

So I guess it’s not a documentation problem. If this is something you can do, give this code to a PDF Express developer:

initWebViewer: (viewer) => {
    const viewerElement = document.getElementById(viewer);
    WebViewer({
        path: 'lib',
        initialDoc: '/files/Blank.pdf',
        licenseKey: 'BobsYourUncle', 
        disabledElements: [
            'leftPanelButton',
            'ribbons',
            'toggleNotesButton',
            'menuButton',
            //                'searchButton',
            'toolsHeader'
        ],
        enableElements: [
            'printButton',
            'downloadButton'
        ]
    }, viewerElement).then((instance) => {
        instance.UI.setTheme('dark');
    })
}

Craig

Hi Craig,

As per above documentation, you can enableElements like this in pdf.js:

then(instance => {

  const { documentViewer, annotationManager } = instance.Core;
  instance.UI.setTheme('dark');
  instance.UI.enableElements( [ 'printButton', 'downloadButton' ] )

The issue is that your disabledElements list includes the ‘menuButton’ which is where the download/print buttons lie:

Let me know if that helps.

Best regards,
Kevin Kim


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