Skip to content

PDFTron Webviewer Open PDF with a user password

I am trying to use the PDFTron WebViewer within a Blazor application to open a PDF with a user password.

I would like to do this without a user dialog but I am can’t figure out how to.

I am calling the initWebView function with the url path to the passworded pdf. This downloads the document and displays a prompt to enter the password. I am able to enter the password manually and the document opens successfully. However, I would like to bypass this prompt by supplying the password as an argument, thus opening the passworded document without any intervention from the user.

var wvInstance;

window.webviewerFunctions = {
    initWebViewer: function (url) {
        const viewerElement = document.getElementById('viewer');
            path: 'lib',
            initialDoc: url,
            fullAPI: true
        }, viewerElement).then(instance => {
            wvInstance = instance;

Thanks for taking the time to help.


You can try using the DocumentViewer#loadDocument API with the password option I think.