问题
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.
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/14898106/portuguese-spanish-accents-with-jspdf