I'm working with Adobe PhoneGap 6.3.3, I'm trying to display a PDF in a hybrid android app with PFDjs. In browser the pdf is diplayed, insted from mobile with PhoneGap App Develover it doesn't work. In console I have this message:
Content Security Policy has been modified to be: <meta
http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'un
safe-inline' https://ssl.gstatic.com * ws:;style-src 'self' 'unsafe-inline' data
: blob:;media-src *;script-src * 'unsafe-inline' 'unsafe-eval' data: blob:;">
I read the pdf from internet with following code:
var url = 'http://www.example.com/foo.pdf';
getBinaryData(url); //call this fn on page load
var callGetDocument = function (response) {
// body...
PDFJS.getDocument(response).then(function getPdfHelloWorld(_pdfDoc) {
console.log('File caricato');
pdfFile = _pdfDoc;
openPage(pdfFile, currPageNumber, 1);
});
}
var getBinaryData = function (url) {
console.log('getBinaryData');
// body...
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
//binary form of ajax response,
callGetDocument(e.currentTarget.response);
};
xhr.onerror = function () {
// body...
console.log("xhr error");
}
xhr.send();
}
I still insert <allow-navigation href="http://*/*" />
in config.xml
.
Can you help me please.
The solution is here
It was a CSP (content-security-policy) issue.
From this site I created a CSP, and I inserted the meta tag in my index.html