繁体   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