Convert html to pdf: utf-8 works only with text, but not html
See original GitHub issueI need to convert html to pdf with jsPDF. It contains UTF-8 symbols (cyrillic). I used fontconverter to generate js-file for my custom font as written here: https://github.com/MrRio/jsPDF
So now example with text works like a charm (from https://github.com/MrRio/jsPDF/blob/master/examples/js/russian.js)
var pdf = new jsPDF('p', 'pt', 'letter');
doc.setFont('PTSans');
doc.setFontSize(10);
doc.text("А ну чики брики и в дамки!", 10, 10);
And example with html ignores my custom font and exports incorrect symbols.
var pdf = new jsPDF('p', 'pt', 'letter');
doc.setFont('PTSans');
doc.setFontSize(10);
pdf.html( "<html>А ну чики брики и в дамки!</html>", { callback: function (pdf) {
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
document.body.appendChild(iframe);
iframe.src = pdf.output('datauristring');
}
});
What I need to do to export html to pdf with unicode symbols?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Convert html to pdf: utf-8 works only with text, but not ... - GitHub
I'm opening this issue again. I need to convert html to pdf with jsPDF. It contains UTF-8 symbols (cyrillic).
Read more >jsPDF convert html to pdf: utf-8 works only with text, but not html
I have not found how to solve this problem and created issue on jspdf github. And I've found that pdfmake.org correctly works with...
Read more >Convert html to pdf: utf-8 works only with text, but not html
I need to convert html to pdf with jsPDF. It contains UTF-8 symbols (cyrillic). I used fontconverter to generate js-file for my custom...
Read more >(M)HTML to PDF conversion does not support Unicode
Hello, I'm trying to convert a .mht/.html file with Aspose. ... InputEncoding = “UTF-8” solves the encoding problem, but the images are not...
Read more >PHP htmlspecialchars() Function - W3Schools
Example. Convert the predefined characters "<" (less than) and ">" (greater than) to HTML entities: <?php $str = "This is some <b>bold</b> text.";...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I use convert file PTSans.ttf https://rawgit.com/MrRio/jsPDF/master/fontconverter/fontconverter.html add in file PTSans-normal.js
import jsPDF from 'jspdf'
And in my App used jsPDF
Finally I’ve decided to use pdfmake, it works correctly with utf-8 symbols.