I am working on AngularJs application which at certain point I have to convert some contents in the web page to PDF format
I tried many things but finally thanks to this Stackoverflow question and using this snippet of code
html2canvas(document.getElementById('exportthis'), {
onrendered: function (canvas) {
var data = canvas.toDataURL();
var docDefinition = {
content: [{
image: data,
width: 500,
}]
};
pdfMake.createPdf(docDefinition).download("Score_Details.pdf");
}
});
I used html2canvas and pdfmake to generate the pdf but the result is not actually a full pdf it just a base64 image contain all the page and exported as pdf file.
I am not able to select any text or click any link it just an image which not the perfect result
Is there anyway to produce real PDF file from HTML via angularJs or Javascript in general
UPDATE :
I tried JsPDF
with there official demo
var doc = new jsPDF();
// We'll make our own renderer to skip this editor
var specialElementHandlers = {
'#editor': function(element, renderer){
return true;
}
};
// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML($('#render_me').get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
but I get this error
jsPDF Warning: rendering issues? provide a callback to fromHTML!
and unfortunately they don't have documentation event on github all the wiki pages are blank pages !!
Thanks in advance!