Loading encrpyted XOD files in Mobile WebViewer

110 views
Skip to first unread message

Matt Bojey

unread,
Aug 20, 2015, 5:53:31 PM8/20/15
to PDFTron WebViewer

When I try to open an encrypted XOD file by passing the options through WebViewer.js it doesn't open in the mobile WebViewer, how can I fix this?

A

There is an issue with encrypted files on mobile that can be solved by using this code in your config file:

$(document).on('viewerLoaded', function(){
   
if($.mobile){
       
var params = window.ControlUtils.getQueryStringMap();
       
if(params.getBoolean('auto_load') === false){
           
var doc = params.getString('d');
           
var streaming = false;
           
var decrypt = window.CoreControls.Encryption.Decrypt;
           
var decryptOptions = {p: YOUR_PASSWORD_HERE, type: 'aes'};
            window
.ControlUtils.byteRangeCheck(function(status) {
               
// if the range header is supported then we will receive a status of 206
               
if (status === 200) {
                    streaming
= true;
                    console
.warn('HTTP range requests not supported. Switching to streaming mode.');
               
}
                window
.readerControl.loadDocument(doc, streaming, decrypt, decryptOptions);
           
           
}, function() {
               
// some browsers that don't support the range header will return an error
                streaming
= true;
                window
.readerControl.loadDocument(doc, streaming, decrypt, decryptOptions);
           
});
       
}
   
}
});

Reply all
Reply to author
Forward
0 new messages