How to set image to fit width of the page using jsPDF?

You can get the width and height of PDF document like below, var doc = new jsPDF(“p”, “mm”, “a4″); var width = doc.internal.pageSize.getWidth(); var height = doc.internal.pageSize.getHeight(); Then you can use this width and height for your image to fit the entire PDF document. var imgData=”data:image/jpeg;base64,/9j/4AAQSkZJ……”; doc.addImage(imgData, ‘JPEG’, 0, 0, width, height); Make sure that … Read more

How to properly use jsPDF library

you can use pdf from html as follows, Step 1: Add the following script to the header <script src=”https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js”></script> or download locally Step 2: Add HTML script to execute jsPDF code Customize this to pass the identifier or just change #content to be the identifier you need. <script> function demoFromHTML() { var pdf = new … Read more

Generate pdf from HTML in div using Javascript

jsPDF is able to use plugins. In order to enable it to print HTML, you have to include certain plugins and therefore have to do the following: Go to https://github.com/MrRio/jsPDF and download the latest Version. Include the following Scripts in your project: jspdf.js jspdf.plugin.from_html.js jspdf.plugin.split_text_to_size.js jspdf.plugin.standard_fonts_metrics.js If you want to ignore certain elements, you have … Read more