Repository navigation
ipptransform: transform annotations for scaled and N-up pages - #223
Open
cyberph3onix wants to merge 1 commit into
Open
cyberph3onix wants to merge 1 commit into
cyberph3onix wants to merge 1 commit into
Conversation
…penPrinting#71) The scaled 1-up path copied Annots without transforming Rect, so annotations were misplaced when a page was scaled to the media, and the N-up path dropped annotations entirely. Add copy_annots(), which applies the cell matrix (and back side transform) to Rect and QuadPoints, scales Border/BS widths and dash arrays, and drops the P, IRT, Parent and Popup references. Use it for both the scaled 1-up and N-up paths.
This branch has not been deployed
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.
Fixes #71.
Problem
Annotsarray was copied unchanged, so annotation rectangles kept their original coordinates while the page content was scaled and centered on the output media. Each annotation's/Palso pulled the input page and its content streams into the output.Changes
copy_page()intoget_cell_matrix().copy_annots(), which creates a new annotation dictionary for each input annotation:RectandQuadPointsthrough the cell matrix (plus the back side transform for duplex) and clips them to the layout cell,BorderandBSwidths and dash patterns (ISO 32000 12.5.2 / 12.5.4),/P,/IRT,/Parentand/Popup, and skips Popup annotations.pdfio_start_page()since PDFio writes the page dictionary there, and it is reset for each copy so collated copies don't pile up duplicate annotations.pdfioPageCopy) is unchanged.Testing
I used a 2-page Letter PDF where each page has a filled box and a Link annotation covering exactly that box (one with a dashed
/Border, one with a/BSdictionary). For each output I rendered it withmutool drawand checked that the pixels just inside eachRectare the box color and the ones just outside are not:print-scaling=fitnumber-up=2(rotated cells)number-up=4-s rotated/-s flippedcopies=3, collated/IRT), scaled 1-up/P)Border example, 2-up (scale 0.63):
/Border [1 1 2 [3 2]]→[.63 .63 1.26 [1.89 1.26]],/BS /W 4 /D [6 3]→/W 2.52 /D [3.78 1.89].tools/run-tests.shpasses (202 tests, 0 failed).Known limitations
/Parent(the field) and the document AcroForm aren't copied, so fields are no longer interactive. That should be fine for print output.Rectbut not rotated (/AP/Matrixisn't changed).