2
我試圖重新創建this example。試圖用英特爾XDK保存PDF文件
但是當我點擊按鈕時,我得到錯誤:「未捕獲的ReferenceError:LocalFileSystem未定義」。
這裏是我的代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jsPDF</title>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jspdf.js"></script>
<script src="js/FileSaver.js"></script>
<script src="js/html2canvas.js"></script>
<script>
function guardar(){
var pdf = new jsPDF('p', 'pt', 'a4');
var source = $('#tabelagastos')[0];
var PDFFILE ='';
var arquivo = prompt("Qual o nome do arquivo?");
pdf.specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true;
}
};
pdf.fromHTML(source, 15, 15, {'width': 170},
function (dispose) {
PDFFILE = pdf.output();
});
//NEXT SAVE IT TO THE DEVICE
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getFile(arquivo +".pdf", {create: true}, function(entry) {
var fileEntry = entry;
entry.createWriter(function(writer) {
writer.onwrite = function(evt) {
alert("Save (root folder)!");
};
writer.write(PDFFILE);
}, function(error) {
alert(error);
});
}, function(error){
alert(error);
});
},
function(event){
alert(evt.target.error.code);
});
}
</script>
</head>
<body>
<h1>EJEMPLO DE JSPDF</h1>
<hr />
<div id="tabelagastos">some text</div>
<input type="button" id="iniciador" value="Guardar" onclick="guardar();">
</body>