Open password protected PDF without showing input prompt

165 views
Skip to first unread message

Matt Parizeau

unread,
Sep 19, 2016, 2:36:23 PM9/19/16
to PDFTron WebViewer
Q:

To open a password protected file we don't want to show user the enter password popup, the password should be set from the code and the user directly sees the PDF file. Is there any way to pass the password to WebViewer?

A:

If you want to pass the password through code you can add the following to a config file:

$(document).on('viewerLoaded', function() {
  readerControl
.getPassword = function(callback) {
    callback
('enter password here');
 
};
});

Bradley Gough

unread,
Jan 16, 2017, 1:03:57 PM1/16/17
to PDFTron WebViewer
Q: Which file do you put this code in as I've tried in ReaderControlConfig.js but it didn't work?

Justin Jung

unread,
Jan 17, 2017, 3:47:48 PM1/17/17
to PDFTron WebViewer
Hello Brad,

The above code can be pasted in ReaderControlConfig.js, or in config.js (https://www.pdftron.com/webviewer/demo/doc/symbols/PDFTron.WebViewer.Options.html#config). Both should work.
I tried pasting it in ReaderControlConfig.js and it worked for me. Do you see any error messages in console log?

Justin Jung
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages