我正在使用 Adobe PhoneGap 6.3.3,我正在尝试在带有 PFDjs 的混合 android 应用程序中显示 PDF。在浏览器中显示pdf,使用PhoneGap App Develover从手机安装它不起作用。在控制台我有这个消息:
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:;">
我使用以下代码从互联网上阅读了pdf:
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();
}
我仍然插入<allow-navigation href="http://*/*" />
. config.xml
你能帮我吗。