簡體   English   中英

Cordova jsPDF - PDF生成,我在Mobile中找不到pdf文件

[英]Cordova jsPDF - PDF generated,I can not find the pdf file in Mobile

我正在使用cordova android設備,我可以進入'console.log(“寫成功”)行;' 但我認為該文件不會出現在保存的位置。

我試過在2個不同的機器人中運行,創建一個pdf文件並保存在任何文件夾中

源代碼http://www.tricedesigns.com/2014/01/08/generating-pdf-inside-of-phonegap-apps/

    //FIRST GENERATE THE PDF DOCUMENT
console.log("generating pdf...");
var doc = new jsPDF();

doc.text(20, 20, 'HELLO!');

doc.setFont("courier");
doc.setFontType("normal");
doc.text(20, 30, 'This is a PDF document generated using JSPDF.');
doc.text(20, 50, 'YES, Inside of PhoneGap!');

var pdfOutput = doc.output();
console.log( pdfOutput );

//NEXT SAVE IT TO THE DEVICE'S LOCAL FILE SYSTEM
console.log("file system...");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {

   console.log(fileSystem.name);
   console.log(fileSystem.root.name);
   console.log(fileSystem.root.fullPath);

   fileSystem.root.getFile("test.pdf", {create: true}, function(entry) {
      var fileEntry = entry;
      console.log(entry);

      entry.createWriter(function(writer) {
         writer.onwrite = function(evt) {
         console.log("write success");
      };

      console.log("writing to file");
         writer.write( pdfOutput );
      }, function(error) {
         console.log(error);
      });

   }, function(error){
      console.log(error);
   });
},
function(event){
 console.log( evt.target.error.code );

謝謝!!

我的問題已經分類了

在cordova javascript中打開PDF

jsPDF和cordova無法查看pdf文件

我試圖將文件寫入root並從那里訪問它,這在非root電話中是不可能的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM