2016-09-30 5 views
1

私はAdobe PhoneGap 6.3.3で作業しています.PDFDjを使用してハイブリッドアンドロイドアプリにPDFを表示しようとしています。ブラウザでは、pdfが表示され、PhoneGap App Develoverでモバイルからインストゥルメントされ、動作しません。Phonejap Cordova with PDFjs securtiy policy error

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ファイルをお読みください:私はまだ​​3210で<allow-navigation href="http://*/*" />を挿入

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(); 
    } 

コンソールでは、私はこのメッセージを持っています。 私を助けてくれますか?

答えて

0

解決策は、CSP(コンテンツ・セキュリティ・ポリシー)問題でしたhere

です。 からthisサイトにCSPを作成しました。index.html