Skip to content

Introducing a pypdf CLI program - close #2160#2170

Closed
Lucas-C wants to merge 3 commits intomainfrom
issue-2160
Closed

Introducing a pypdf CLI program - close #2160#2170
Lucas-C wants to merge 3 commits intomainfrom
issue-2160

Conversation

@Lucas-C
Copy link
Copy Markdown
Member

@Lucas-C Lucas-C commented Sep 7, 2023

What's missing:

  • maybe more tests?
  • a dedicated documentation page?

@Lucas-C Lucas-C changed the title Introducing a pypdf CLI program Introducing a pypdf CLI program - close #2160 Sep 7, 2023
@Lucas-C Lucas-C requested a review from pubpub-zz September 7, 2023 17:30
base: Any
hival: Any
if isinstance(color_space, ArrayObject) and color_space[0] == "/Indexed":
if isinstance(color_space, ArrayObject) and len(color_space) == 4 and color_space[0] == "/Indexed":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How is this change related to the CLI?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a fixup for a bug.

Introducing this CLI and the related unit tests revealed this issue:

  File "/opt/pypdf/pypdf/filters.py", line 851, in _handle_flate
    color_space, base, hival, lookup = (
ValueError: not enough values to unpack (expected 4, got 3)

There is also another bug spotted there:
https://github.com/py-pdf/pypdf/blob/issue-2160/tests/test_cli.py#L91

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Lucas-C
can you provide the pdf showing the issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, this is one of py-pdf test samples: https://github.com/py-pdf/pypdf/blob/main/resources/AutoCad_Diagram.pdf

The error was raised by simply calling pypdf extract-images AutoCad_Diagram.pdf

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I reported the 2nd bug there: #2176

Should I open a distinct issue for the 1st bug, regarding filters.py & color_space?

@Lucas-C
Copy link
Copy Markdown
Member Author

Lucas-C commented Sep 7, 2023

This PR can probably be closed, given that https://github.com/py-pdf/pdfly offers similar functionalities

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage: 98.66% and project coverage change: +0.04% 🎉

Comparison is base (05f2a65) 94.25% compared to head (cdc7139) 94.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2170      +/-   ##
==========================================
+ Coverage   94.25%   94.29%   +0.04%     
==========================================
  Files          42       43       +1     
  Lines        7556     7630      +74     
  Branches     1487     1499      +12     
==========================================
+ Hits         7122     7195      +73     
  Misses        266      266              
- Partials      168      169       +1     
Files Changed Coverage Δ
pypdf/__main__.py 98.64% <98.64%> (ø)
pypdf/filters.py 94.52% <100.00%> (ø)

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@MartinThoma
Copy link
Copy Markdown
Member

I will not merge the change done with __main__ as pypdf should not become an application. We have pdfly for that.

However, the change to filters and maybe a part of the test looks unrelated / might be interesting to merge. Do you want to (1) adjust the PR or (2) open a new PR or (3) should I take care of it?

@MartinThoma
Copy link
Copy Markdown
Member

@Lucas-C How should we continue with this PR?

@MartinThoma
Copy link
Copy Markdown
Member

@Lucas-C Friendly reminder :-) How do you want to continue with this PR?

@MartinThoma
Copy link
Copy Markdown
Member

I'm closing this PR as I assume that this will not have a follow-up. If I'm wrong, we can still re-open :-)

@MartinThoma MartinThoma closed this Oct 1, 2023
@stefan6419846 stefan6419846 deleted the issue-2160 branch March 1, 2025 19:58
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.

4 participants