我試圖爲我的應用程序生成一個PDF發票,我可以到'console.log(「寫入成功」);''行'但我無法找到該文件。請幫忙!!!我怎樣才能將它保存到我的手機中的文件夾?jsPDF和cordova無法查看pdf文件
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);
你可以發佈console.log(fileSystem.root.fullPath)的結果嗎? – Del
它的到來/ – Philomath