Question

How can I manage to get special characters in a PDF file generated with jsPDF?

The texts are dynamically loaded through AJAX. Some possible chars are à, É, Ç and õ. I, up to now, didn't get how to do this.

Était-ce utile?

La solution

You must download the last version of jsPDF, there will be a file called jspdf.plugin.standard_fonts_metrics.js, just reference that script from your html page and that would be more than enough to user special caracters would be a simple line like this:

<script src="jspdf.plugin.standard_fonts_metrics.js"></script>
<script>
    doc.text(74, 25, 'Evaluación de prueba');
</script>

This worked for me.

Autres conseils

I had some troubles with it to show the PDF inside a DIV, i solved with this code

var url = doc.output('dataurlstring');

$('embed').attr('src',url);

$('<div id="divPdf" class ="hidden" title="PDF - ORDEN DEL DIA"><embed width="95%" height="95%" name="plugin" align="center" src="" type="application/pdf"> </div>').appendTo('body');

Hope it Helps

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top