Explicitly define default value for CIDToGIDMap#1019
Conversation
|
@PadraigGalvin Can you please enlighten us how to create PDF/A-3b documents using PDFKit? |
|
@sakarit you essentially just have to add some metadata and use a reduced feature set. Using a PDF validator can help figuring out if the features you are using are compatible with the spec or not. I was able to gather bits and pieces from various libraries for other languages to put something together. Once you understand the spec it's not really that hard to do with PDFKit. Finding the info was the difficult part for me anyway! Here is some sample code that should help: https://github.com/PadraigGalvin/pdfkit-pdfa-sample |
|
@PadraigGalvin Thank you. While I waited for your answer I figured it out by myself and ended up with a similar solution. :) For anyone interested the above solution works and can be used to generate PDF/A-2b and PDF/A-3b documents since they are quite similar standards. You can toggle between them by changing this part of the XMP metadata: |
|
No problem @sakarit, glad to hear you solved it ! |
|
@PadraigGalvin Thanks for your demo code. I was able to successfully generate a PDF file PDF-A-3b-sample.pdf which correctly opens in the browser as well as my default PDF viewer (which claims it to be valid PDF/A-3b standard). But Acrobat Reader does not display any content. I also tried to validate the file (using the free 'verapdf' validator), but it throws an error ( |
|
@walderich there seems to be a minor issue with your sample file compared to mine. The color profile name seems to be provided as an invalid reference instead of a string. Here's your file: Here's what it should be: When creating PDF objects, PDFKit treats regular Javascript strings and instances of the string object differently. Regular strings are used as references and string objects are added as text. It's an easy trap to fall into, just make sure you are using const refOutputIntent = doc.ref({
Type: 'OutputIntent',
S: 'GTS_PDFA1',
Info: new String('sRGB IEC61966-2.1'),
OutputConditionIdentifier: new String('sRGB IEC61966-2.1'),
DestOutputProfile: refColorProfile,
});
refOutputIntent.end(); |
|
@PadraigGalvin Thanks a lot for your quick reply. I indeed removed the This resolves my main issue as the PDF is now correctly displaying in Acrobat Reader. Thanks again! |
|
You're welcome @walderich, I'm glad it helped! |
I'm using PDFKit to make PDF/A - 3B documents. Thanks to PDFKit's API it's not too difficult to do, but I've come across a minor issue which cannot be solved via the API.
What kind of change does this PR introduce?
CIDToGIDMap is an optional property of Type 2 CIDFonts with a default value of "Identity"1. However, the property is required by the PDF/A specification2. Defining this property does not change the behaviour of PDF 1.3 to 1.7 documents but does allow PDFKit to be used to generate valid PDF/A files.
What is the current behavior?
CIDToGIDMap property is not set so viewers will presume "Identity" by default.
What is the new behavior?
CIDToGIDMap is property is explicitly set to "Identity".
Checklist:
This is my first PR so feedback is welcome.
Related to #369.