cesarvr / pdf-generator

Cordova plugin to generate pdf in the client-side
MIT License
106 stars 62 forks source link

Problem with saving PDF #51

Closed MarouaneSH closed 6 years ago

MarouaneSH commented 6 years ago

Hello guys , i had successfly installed this plugin in IONIC 3 project . everything work great , but how can save as PDF ? because in documentation they just print console.log(success) ??? ! if i look to my output console , this is the result

console.log: sucess: JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVhdG9yIChDaHJvbWl1bSkKL1Byb2R1Y2VyIChT a2lhL1BERiBtNTUpCi9DcmVhdGlvbkRhdGUgKEQ6MjAxNzEwMjUxODIzNDgrMDAnMDAnKQovTW9k RGF0ZSAoRDoyMDE3MTAyNTE4MjM0OCswMCcwMCcpPj4KZW5kb2JqCjIgMCBvYmoKPDwvRmlsdGVy ...............................

cesarvr commented 6 years ago

console.log: sucess: JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVhdG9yIChDaHJvbWl1bSkKL1Byb2R1Y2VyIChT a2lhL1BERiBtNTUpCi9DcmVhdGlvbkRhdGUgKEQ6MjAxNzEwMjUxODIzNDgrMDAnMDAnKQovTW9k RGF0ZSAoRDoyMDE3MTAyNTE4MjM0OCswMCcwMCcpPj4KZW5kb2JqCjIgMCBvYmoKPDwvRmlsdGVy

This is a base64 representation of the PDF file, now you need to turn that into a binary format.

Or use type shared:


     pdf.htmlToPDF({
            data: "<html> <h1>  Hello World  </h1> </html>",
            documentSize: "A4",
            landscape: "portrait",
            type: "share" //use share to open the open-with-menu.
        }, this.success, this.failure);