-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalized doc does not conform to PDF 1.7 standards #1548
Comments
Okay, we've figured out what the issue was. A few weeks back, we went through the entire project and fixed all the linter errors and warnings that the project had. Further down from the code I posted in the snippet above, we set up the ICC profile for the PDF like this:
The problem was with the const rgbString. Before we did our linter fixes, that line was originally:
Our linter didn't like it because of the rule |
@fuzailgilani that's the intended behavior by design, see https://github.com/foliojs/pdfkit/blob/master/lib/object.js#L46 |
@Deku-nattsu The code you linked doesn't indicate to me that this is intended behavior, it just looks like the spot where the edge-case of being passed a primitive string isn't covered. And if it is intended behavior that it expects a String object instead of a primitive string, then it should throw a type error when you pass in a primitive-type string. It can't possibly be intended behavior to simply create a broken PDF if one of the inputs is the wrong type. |
@fuzailgilani The condition for string literals is right above that line lol In the pdf spec there are two types of string that can be used for dictionaries, you have I understansd your frustration but the solution of making it type safe will require the team to define almost every object in the pdf spec since some keys accept In the meanwhile i suggest having the spec around as reference and watch for the type of every key and use String objects for |
Bug Report
Description of the problem
The PDF that is generated using PDFKit can be opened in most PDF readers (e.g. Preview, browsers, etc.), but when we try to open it in Adobe Acrobat, it complains that the file is corrupted, giving the error code 135, which indicates that the file does not conform to PDF 1.7 standards. I ran one of the files through an online tool to validate the standard and it gave the following results:
We first noticed the issue with PDFKit version 0.13.0, and thought maybe upgrading to the latest version 0.15.0 would fix it, but no luck.
Code sample
We have a couple thousand lines of code for PDF generation as it's pretty central to our application and there's a lot of branching logic, but for now I'll just include how we initialize the document:
Your environment
The text was updated successfully, but these errors were encountered: