Reputation: 19
I want the client to download the desired #por div in PDF format by clicking the #btn button. My site is WordPress site.
I use jsPDF and it worked. But my problem is that jsPDF does not support utf-8.(I use Persian language in #por div)
What should I do? please guide me. Thankful
<!DOCTYPE html>
<html>
<div class="por1" id="por">...</div>
<button class="btn btn-info" id="btn" onclick="pdf()" target="_blank" >Download PDF</button>
<script>
function pdf()
{
var doc = new jsPDF();
var elementHandler = {
'#ignorePDF': function (element, renderer) {
return true;
}
};
var source = window.document.getElementById('por').innerHTML;
doc.fromHTML(
source,
15,
15,
{
'width': 180,'elementHandlers': elementHandler
});
doc.save("dataurlnewwindow");
}
</script>
</html>
Upvotes: 0
Views: 2109
Reputation: 113
Man, I'd like to help you, but unfortunately, I don't know the clue :( Sorry, but I've got this question on this website where a guy explained everything you need to know :) I hope it was useful enough!
Generate pdf from HTML in div using Javascript
Upvotes: 1