Portuguese/Spanish accents with jsPDF

此生再无相见时 提交于 2019-12-02 03:49:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!