Convert HTML to PDF using jQuery

brsy

nah mang
May 12, 2011
1,530
272
I've tried jsPDF and it hasn't work. Anyone have an idea? I want a specific div (let's call it #target) to be converted into a PDF when the I click a link that says "download to PDF".
 

JayC

Always Learning
Aug 8, 2013
5,497
1,398
  1. Go to and download the latest Version.
  2. 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
var doc =new jsPDF();
var elementHandler ={
'#ignorePDF':function(element, renderer){returntrue;
}};
var source = window.document.getElementsByTagName("#target")[0];
doc.fromHTML(
source,15,15,{'width':180,'elementHandlers': elementHandler
});

doc.output("dataurlnewwindow");


source:
 

brsy

nah mang
May 12, 2011
1,530
272
I tried that already, but it I couldn't get it to work. Copying and pasting it from Stackoverflow isn't going to help me.
 

Users who are viewing this thread

Top