@Joseph-Benguira said in save as pdf:
derstand your need correctly, I believe you want to generate the PDF on the client side, so yes you can still use the same library "jsPDF".
From their documentation I can see you can load it from a CDN, so just drop a block of HTML source code on your page, then paste this in it
Hi,
Thanks Joseph. Yes, this could work. My question is how I can mark the dynamic section of my page (DS2=list of products) to be my "pdfArea". Can't get it to work. The genereted pdf contains:
"[DS2=Product_name]
[DS2=Category]
[DS2=temp_Company]"
my test:
<div id="pdfArea">
<h3>Produkter</h3>
...
...
...
</div>
<div id="editor"></div>
<button id="cmd">Save list as pdf</button>
<script>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#pdfArea').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('mobelfakta-lista.pdf');
});
</script>