Skip to content

DEP: Replace PdfWriter method add_js - #3979

Open
j-t-1 wants to merge 6 commits into
py-pdf:mainfrom
j-t-1:action
Open

DEP: Replace PdfWriter method add_js#3979
j-t-1 wants to merge 6 commits into
py-pdf:mainfrom
j-t-1:action

Conversation

@j-t-1

@j-t-1 j-t-1 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Replace add_js with add_action. The more generic name gives
extensibility if more action types are implemented.
Closes #3776.

j-t-1 added 2 commits August 18, 2026 06:07
Replace add_js with add_action. The more generic name gives
extensibility if more action types are implemented.
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.98%. Comparing base (f6853cc) to head (22f0a45).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3979   +/-   ##
=======================================
  Coverage   97.98%   97.98%           
=======================================
  Files          57       57           
  Lines       11104    11111    +7     
  Branches     2080     2080           
=======================================
+ Hits        10880    10887    +7     
  Misses        125      125           
  Partials       99       99           

☔ View full report in Codecov by Harness.
📢 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.

@j-t-1

j-t-1 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

This method would be better called open_action. add_action is used for the AA key entry in a page object. There is also an AA key entry in the catalog dictionary.

The value of OpenAction (2.0 specification):

A value specifying a destination that shall be displayed or an action that shall be performed when the document is opened. The value shall be either an array defining a destination or an action dictionary representing an action.

Thus this would be better, with the method having different paths on which type it is given (using isinstance):
open_action(self, action: Action | Destination)

@stefan6419846 as well as your code review, welcome guidance on the above changes.

@stefan6419846 stefan6419846 left a comment

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.

This method would be better called open_action. add_action is used for the AA key entry in a page object. There is also an AA key entry in the catalog dictionary.

I am sorry, but I have some trouble following what you try to say here.

Thus this would be better, with the method having different paths on which type it is given (using isinstance):
open_action(self, action: Action | Destination)

open_action sounds like a property and not like a method to change/add something here. A Destination is no action, thus the name would be confusing.

Comment thread pypdf/_writer.py
Comment thread pypdf/_writer.py Outdated
@j-t-1
j-t-1 requested a review from stefan6419846 August 22, 2026 19:49
@j-t-1

j-t-1 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

This method would be better called open_action. add_action is used for the AA key entry in a page object. There is also an AA key entry in the catalog dictionary.

I am sorry, but I have some trouble following what you try to say here.

Thus this would be better, with the method having different paths on which type it is given (using isinstance):
open_action(self, action: Action | Destination)

open_action sounds like a property and not like a method to change/add something here. A Destination is no action, thus the name would be confusing.

How about add_open_action(self, action: Action)?

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.

Replace the PdfWriter method add_js with add_action

2 participants