Repository navigation
Add tagged PDF and PNG predictor samples, document 017 - #45
Merged
Merged
Conversation
MartinThoma
commented
Oct 30, 2026
Member
- 030-tagged-pdf: a tagged PDF 2.0 file with a hand-written structure tree, and the script that creates it.
- 031-png-predictors: an RGB image with 8 bits per component, stored once without a predictor and once with /Predictor 15, using the PNG filters None, Sub, Up, Average and Paeth in bands of 50 rows. Both images must decode to the same data.
- 032-png-predictors-low-bit-depth: the same for grayscale images with 1, 2 and 4 bits per component, where the Sub, Average and Paeth filters use the byte to the left.
- 017-unreadable-meta-data: a README explaining the deliberate damage of the file and why its entry in files.json cannot be checked.
* 030-tagged-pdf: a tagged PDF 2.0 file with a hand-written structure tree, and the script that creates it. * 031-png-predictors: an RGB image with 8 bits per component, stored once without a predictor and once with /Predictor 15, using the PNG filters None, Sub, Up, Average and Paeth in bands of 50 rows. Both images must decode to the same data. * 032-png-predictors-low-bit-depth: the same for grayscale images with 1, 2 and 4 bits per component, where the Sub, Average and Paeth filters use the byte to the left. * 017-unreadable-meta-data: a README explaining the deliberate damage of the file and why its entry in files.json cannot be checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MartinThoma
added a commit
to py-pdf/pypdf
that referenced
this pull request
Oct 30, 2026
Update the sample files to py-pdf/sample-files#45, which adds 031-png-predictors and 032-png-predictors-low-bit-depth. Each page of these files shows the same image twice: once without a predictor, and once with /Predictor 15, using the PNG filters None, Sub, Up, Average and Paeth in bands of 50 rows. Both images must decode to the same data. The 8-bit RGB image of 031-png-predictors does. The grayscale images of 032-png-predictors-low-bit-depth, with 1, 2 and 4 bits per component, do not: for fewer than 8 bits per pixel, the bytes per pixel used by the Sub, Average and Paeth filters are rounded down to 0 instead of up to 1. These cases are marked as strict xfail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Which PDF/UA standard does the tagged PDF file target? According to veraPDF, neither PDF/UA-1 nor PDF/UA-2 are met by the file. |
Member
Author
|
It doesn't target any standard. I simply wanted to have a PDF with some tags so that we could start adding support for tagged PDFs :-) Having an example file that follows one of the standards would be ideal, though 👍 |
stefan6419846
pushed a commit
to py-pdf/pypdf
that referenced
this pull request
Oct 30, 2026
) * TST: Compare PNG predicted images with images without a predictor Update the sample files to py-pdf/sample-files#45, which adds 031-png-predictors and 032-png-predictors-low-bit-depth. Each page of these files shows the same image twice: once without a predictor, and once with /Predictor 15, using the PNG filters None, Sub, Up, Average and Paeth in bands of 50 rows. Both images must decode to the same data. The 8-bit RGB image of 031-png-predictors does. The grayscale images of 032-png-predictors-low-bit-depth, with 1, 2 and 4 bits per component, do not: for fewer than 8 bits per pixel, the bytes per pixel used by the Sub, Average and Paeth filters are rounded down to 0 instead of up to 1. These cases are marked as strict xfail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * TST: Make xfail strict by default With xfail_strict, a test marked as xfail that passes makes the test run fail, so that marks of fixed issues do not stay behind. test_issue_2336 is the only test that passed unexpectedly. The whitespace issue #2336 was fixed by d5233a0 "BUG: Improve handling of spaces in text extraction (#2882)" in October 2024, so its xfail mark is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * TST: Correct outdated and wrong expectations of image tests * test_get_images: imagemagick-lzw.pdf was marked as xfail for "broken image extraction" since #1330. The image is extracted correctly, but as Im0.tiff: images using the LZW filter are saved as TIFF since that PR. Expect Im0.tiff and remove the mark, and the commented-out mark of imagemagick-ASCII85Decode.pdf. * test_4bits_image: the reference PNG was extracted with pypdf (#3761) and is black, like the image pypdf extracts. The 16 x 16 /DeviceGray image is a gradient, with the gray level y in each pixel of row y, as poppler renders it. Compare with this gradient instead, and mark the test as xfail, as 4-bit /DeviceGray images are extracted as black palette images. * Refer to #4308 in the xfail reason of the PNG predictor tests with fewer than 8 bits per pixel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * TST: Refer to #4316 in the xfail reason of test_4bits_image Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.