Skip to content Skip to sidebar Skip to footer

Special Characters Are Not Being Exported To Pdf

I am using jspdf to export the data to PDF. When the data is exported to the PDF, special characters are not displayed in the PDF. Please find the demo plunker : https://plnkr.co/

Solution 1:

According to the docs, doc.addHTML is being deprecated in favor of a vector able API. This method indeed seems to lack some features, like the rendering of CSS list-style-type.

I am not sure if doc.fromHTML is this new API (currently absent from the docs), but it seems to be able to render these :

var doc = newjsPDF();
doc.fromHTML(ul, 15, 15, {
  width: 170
});
doc.addPage();
doc.fromHTML(ol, 15, 15, {
  width: 170
});
var blob = doc.output('blob');
var i = document.createElement('iframe');
i.width = '100%';
i.height = window.innerHeight;
i.src = URL.createObjectURL(blob);
var a = document.createElement('a');
a.download = 'doc.pdf';
a.innerHTML = 'download (for chrome...)';
a.href = i.src;
document.body.appendChild(a);
document.body.appendChild(i);
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script><divid="ul"><ul><li>first</li><li>second</li></ul></div><divid="ol"><ol><li>first</li><li>second</li></ol></div>

So here is your fixed plnkr.

Solution 2:

As I'm reading at the plugin you used at github it appears that you may need UTF-8 charset to do it. you can try to add meta charset UTF-8 on your head html which is you will used it for generate PDF

or if you are using nodeJS as back end. you can try phantom JS PDF . I did used it before and its even supported symbolic language like arabian, chinese, russian, japanese and more (with some configurations)

edited for better readability

Post a Comment for "Special Characters Are Not Being Exported To Pdf"