Conversation
Flattening a link or a form field that has no /N appearance registered a Form XObject under a heap-allocated name and then freed that name. pdfioDictSetObj() keeps the key pointer, so the page /XObject dictionary was corrupt by the time the flattened file was written. Reopening it failed and cfFilterPDFToPDF() exited 1. Chrome's direct-to-CUPS PDF hits this for every hyperlink. Skip annotations that have nothing to paint. Text and choice fields that still carry a value are synthesized under a PDFio-owned name. Fixes OpenPrinting#246
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pdftopdfexits 1 on PDFs whose annotations have no appearance stream. Chrome's direct-to-CUPS print path builds one/Linkannotation per hyperlink and does not give those annotations an/AP/Nstream, so printing a normal web page fails inside the universal filter. A saved PDF of the same page, which has no such annotations, prints.The no-appearance branch of
flatten_pdf()still created a Form XObject and registered it withpdfioDictSetObj()under amalloc'd name, thenfreed that name.pdfioDictSetObj()keeps the caller's key pointer. After the name was freed, every/XObjectkey in the flattened page was a dangling pointer, the flattened file could not be reopened, andcfFilterPDFToPDF()returned 1 with no further error. One link is enough for this to happen intermittently. A page with more links fails every time. The log still said "special case ignore annotation with no appearance" while doing the opposite.Annotations with nothing to paint (links, and form fields that have no value) are now skipped. Text and choice fields that still carry a value are synthesized, and the XObject name is a PDFio-owned string so it stays valid until the file is closed.
annotation_contentsis allocated withcalloc, so a skipped slot cannot be a garbage pointer.cupsfilters/test-pdftopdf-no-appearance.shruns a one-page PDF with 16 appearance-less link annotations throughpdftopdfand checks that the output opens and has a page. On current master that fixture produces an empty file and exit status 1.Fixes #246