Generating PDFs on Android
How to create a PDF for the visible DOM elements using the jsPDF library.
Step-by-step guide
- You need to use the latest code from their github page.
- You need to add jsPDF and rasterizeHTML.js (or html2canvas.js) as external JS in answerSpace setup.
- You will need to use the Cordova 3.3.0 File API to save/copy the generated PDF to the desired location on the device.
- To generate the pdf, simply do:
Example
var pdf = new jsPDF(); pdf.addHTML($(":visible").html()); // Generates PDF for the visible DOM elements pdf.save(‘/path/to/save/test.pdf’);
Related articles