Description
Description
(Moved from svg2pdf.js issue 190 tracker, as it is happens to be unrelated to the SVG layer.)
Using an added unicode font in SVG results in broken PDF. There are no warnings or errors logged in the console.
On Windows, Adobe Reader says "There as an error processing a page. There as a problem reading this document (135)". Sumatra displays a blank page or unrelated characters in an unrelated font (pdf default serif?).
On macOS Big Sur 11.5.2, "Preview" displays a blank page.
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.
However, the PDF renders correctly with anything Poppler-based on Linux or with PDF readers built into Firefox or Chrome browsers.
Using version jspdf.umd.js : 2.3.1
To reproduce
HTML
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="../../../current/lib.js/nih/jspdf/jspdf.umd.js"></script>
<script src="../../../current/lib.js/nih/fonts/LiberationSans-Bold-bold.js"></script>
<script src="asypdf-bare.js" defer></script>
</body>
asypdf-bare.js
const { jsPDF } = window.jspdf;
var pageWidth = 85.6,
pageHeight = 53.98;
var pdf = new jsPDF('l', 'mm', [pageWidth, pageHeight], true);
pdf.setFont('Liberation Sans', 'bold');
pdf.text(5, 5, 'wazzat?');
pdf.save('result.pdf');
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 other PDF page sizes.
If an additional font is not loaded, or when using default fonts, the PDF renders just fine.
Platform
- OS: Xubuntu 20.04
- Browser: Firefox 91.0.2, Chromium Ungoogled 91.0.4472.77