Skip to content Skip to sidebar Skip to footer

Intel-xdk + Jspdf

I'm trying to export an table from my app to an pdf file! This working normal in emulator, but I can't save the file when the app is installed in my Moto G, I'm using the code bell

Solution 1:

I have found the way:

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

Post a Comment for "Intel-xdk + Jspdf"