Skip to content

ENH: Add support for BrotliDecode filter (PDF 2.0) #3223 #3254

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ash01ish
Copy link

Implements the BrotliDecode filter as specified in ISO 32000-2:2020, Section 7.4.11. Adds necessary constants, integrates the filter into the decoding logic, includes brotli as an optional dependency, adds unit tests, and updates documentation.

Closes #3223

@ash01ish ash01ish changed the title feat: Add support for BrotliDecode filter (PDF 2.0) #3223 ENH: Add support for BrotliDecode filter (PDF 2.0) #3223 Apr 13, 2025
Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.60%. Comparing base (b185ab3) to head (00e124c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3254   +/-   ##
=======================================
  Coverage   96.60%   96.60%           
=======================================
  Files          53       53           
  Lines        8973     8992   +19     
  Branches     1659     1662    +3     
=======================================
+ Hits         8668     8687   +19     
  Misses        183      183           
  Partials      122      122           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ash01ish ash01ish force-pushed the feat/add-brotli-decode branch 7 times, most recently from 1573164 to d339bc8 Compare April 14, 2025 02:15
Copy link
Collaborator

@stefan6419846 stefan6419846 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Is the official specification available in the meantime?

Apart from this, I have left some comments I stumbled upon during the review.

@ash01ish ash01ish force-pushed the feat/add-brotli-decode branch 2 times, most recently from 274ed94 to 4dd3fa0 Compare April 14, 2025 09:21
@ash01ish
Copy link
Author

Reverting the requirements.txt files to main will show an error that the package is not installed. Is there any other way to get them installed? - I have added them in dev.in and ci.in - expecting that the req will be generated while running the pipeline.

@ash01ish
Copy link
Author

Is the official specification available in the meantime?

The official specification for Brotli compression in PDF is not yet released. However, the PDF Association has announced its upcoming inclusion in PDF 2.0. Sample PDF files are available for developers to begin testing. https://pdfa.org/brotli-compression-coming-to-pdf/

@stefan6419846
Copy link
Collaborator

Reverting the requirements.txt files to main will show an error that the package is not installed. Is there any other way to get them installed? - I have added them in dev.in and ci.in - expecting that the req will be generated while running the pipeline.

You can change the .txt variants, but ONLY for the actual dependency.

@ash01ish ash01ish force-pushed the feat/add-brotli-decode branch from 8b4514f to b7a5245 Compare April 14, 2025 12:05
@ash01ish ash01ish force-pushed the feat/add-brotli-decode branch from 672f080 to a4fdd61 Compare April 14, 2025 15:18
def test_brotli_missing_installation_mocked():
"""Verify BrotliDecode raises ImportError if brotli is not installed."""
# Import pypdf.filters *after* patching sys.modules
import pypdf.filters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this as local imports?

@ash01ish ash01ish requested a review from stefan6419846 April 17, 2025 17:08
@ash01ish ash01ish force-pushed the feat/add-brotli-decode branch from 1f83b52 to 025226a Compare April 21, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BrotliDecode filter
2 participants