Closed
Description
When generating a PDF and a custom font title with a space in its name is used, the resulting PDF is not PDF/A compliant and even fails to open in some PDF readers (such as awful Adobe Acrobat Reader).
Here is a example with jsPDF v2.11 and the default windows fonts Calibri and Comic Sans. From my testing, any ttf font will do:
var doc = new jsPDF(); // create document
doc.text("This is the default font", 100, 20, "center"); // write text
doc.save("Standard.pdf"); // save pdf
doc.addFont("https://server/calibri.ttf", "Calibri", "normal"); // embed font
doc.setFont("Calibri"); // set font
doc.text("This is Calibri", 100, 40, "center"); // write text
doc.save("Standard with Calibri.pdf"); // save with a custom font embedded
doc.addFont("https://server/comicsans.ttf", "Comic Sans", "normal"); // embed font
doc.setFont("Comic Sans"); // set font
doc.text("This is Comic Sans with a space in its name", 100, 60, "center"); // write text
doc.save("Standard with Calibri and Comic Sans.pdf"); // save with a custom font embedded
Using https://www.pdf-online.com/osa/validate.aspx to test the invalid PDF shows the following:
Validating file "Standard with Calibri and Comic Sans.pdf" for conformance level pdf1.3
The "endobj" keyword is missing.
The key Encoding is required but missing.
The key DescendantFonts is required but missing.
The document does not conform to the requested standard.
The file format (header, trailer, objects, xref, streams) is corrupted.
The document doesn't conform to the PDF reference (missing required entries, wrong value types, etc.).
The document does not conform to the PDF 1.3 standard.
Simply removing the space, making it "ComicSans" instead, fixes this issue and neither the validator or Acrobat Reader will complain anymore.
It is probably related to issue #2593
Metadata
Metadata
Assignees
Labels
No labels