Closed popobol closed 2 years ago
Thanks for reporting this. I think it's a bug in jsPDF, though. When run this
pdf.setFont('Liberation Sans', 'bold')
pdf.text(30, 30, 'foo bar')
pdf.save('result.pdf')
it also creates an invalid PDF. Please move this issue to jsPDF. There have been similar issues with some fonts in the past. A workaround might be to use a different font.
Thanks for reporting this. I think it's a bug in jsPDF, though. When run this
pdf.setFont('Liberation Sans', 'bold') pdf.text(30, 30, 'foo bar') pdf.save('result.pdf')
it also creates an invalid PDF. Please move this issue to jsPDF. There have been similar issues with some fonts in the past. A workaround might be to use a different font.
Thanks! All apologies for raising it in a wrong channel. New issue opened with jsPDF: https://github.com/MrRio/jsPDF/issues/3245
Closing it here.
Description
Using an added unicode font in SVG results in broken PDF. There are no warnings or errors logged in the console.
On Windows, Sumatra displays a blank page, Adobe Reader says "There as an error processing a page. There as a problem reading this document (135)". On macOS Big Sur 11.5.2, "Preview" displays a blank page.
However, the PDF renders correctly with anything Poppler-based on Linux or with PDF readers built into Firefox or Chrome browsers.
Various PDF tools report problems with the file. E.g. pdfunite : "Syntax Error: Dictionary key must be a name object" mutool : "error: invalid key in dict" gs -sDEVICE=pdfwrite : "Error: obj definition followed by multiple tokens" etc.
Versions used: jspdf.umd.js : 2.3.1 svg2pdf.umd.js : 2.1.0
To reproduce
HTML
asypdf.js
The UMD "LiberationSans-Bold-bold.js" (LiberationSans-Bold-bold.js.zip attached) was generated with jsPDF fontconverter tool from a TTF coming with default Xubuntu installation. The behaviour is the same with Free Sans, or Noto Sans fonts.
The behaviour is the same with SVG units changed to px.
If an additional font is not loaded, or when using default fonts, the PDF renders just fine.
Using the same font file to generate a PDF using jsPDF, but without SVG/svg2pdf stage, works ok.
Platform