Skip to content

ENH: Preserve links in added pages also when links come from merged-in pages - #3400

Open
larsga wants to merge 1 commit into
py-pdf:mainfrom
larsga:issue-3290-part-2
Open

ENH: Preserve links in added pages also when links come from merged-in pages#3400
larsga wants to merge 1 commit into
py-pdf:mainfrom
larsga:issue-3290-part-2

Conversation

@larsga

@larsga larsga commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

This is the last part of the implementation of issue 3290.

It causes the tests to be slow because named_destinations is not cached, but I'm leaving that as a separate task.

@larsga
larsga force-pushed the issue-3290-part-2 branch from 90563bc to 016e81f Compare July 28, 2025 10:46
@larsga larsga changed the title Preserve links in added pages also when links come from merged-in pages ENH: Preserve links in added pages also when links come from merged-in pages Jul 28, 2025
@larsga
larsga force-pushed the issue-3290-part-2 branch 5 times, most recently from 75cb5ad to 956e3fd Compare July 28, 2025 11:23
@codecov

codecov Bot commented Jul 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.80%. Comparing base (23339e5) to head (a9da8f6).
⚠️ Report is 36 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3400      +/-   ##
==========================================
+ Coverage   97.70%   97.80%   +0.10%     
==========================================
  Files          55       55              
  Lines       10410    10526     +116     
  Branches     1928     1965      +37     
==========================================
+ Hits        10171    10295     +124     
+ Misses        133      128       -5     
+ Partials      106      103       -3     

☔ 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.

Comment thread pyproject.toml Outdated
@stefan6419846

Copy link
Copy Markdown
Collaborator

It causes the tests to be slow because named_destinations is not cached, but I'm leaving that as a separate task.

This is an unexpected side effect of these changes and as we know that it decreases performance, I cannot merge this PR safely without addressing the speed issues - ideally as a separate PR.

@stefan6419846 stefan6419846 added needs-discussion The PR/issue needs more discussion before we can continue needs-change The PR/issue cannot be handled as issue and needs to be improved labels Jan 9, 2026
@larsga
larsga force-pushed the issue-3290-part-2 branch 4 times, most recently from 2c388a3 to eba0fee Compare May 12, 2026 11:58
@larsga

larsga commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Now that PR #3442 has been merged, and I've fixed the issue you found, I guess this one might be ready to merge as well?

@stefan6419846 stefan6419846 removed needs-discussion The PR/issue needs more discussion before we can continue needs-change The PR/issue cannot be handled as issue and needs to be improved labels May 12, 2026

@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.

Thanks for the updates. I have left some remarks where I see further changes to consider.

Comment thread pypdf/generic/_link.py
Comment thread pypdf/generic/_link.py Outdated
Comment thread pypdf/generic/_link.py Outdated
Comment thread pypdf/generic/_link.py
Comment thread pypdf/_page.py Outdated
Comment thread tests/test_merger.py Outdated
@larsga
larsga force-pushed the issue-3290-part-2 branch 3 times, most recently from 11fb5d3 to ecc1d1c Compare May 28, 2026 09:00
@larsga

larsga commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

This should be ready for review now.

@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.

Thanks for the updates.

Besides the inline comments: The modifications to pypdf/generic/__init__.py and NamedReferenceLink.__init__ breaks backwards compatibility. As they have been exposed as public API, we unfortunately need to keep this backwards-compatible with a proper deprecation period and cannot simply remove them. Please indicate if you need help with this, especially with the __init__.py part.

Comment thread pypdf/_page.py Outdated
Comment thread tests/test_merger.py


@pytest.mark.enable_socket
def test_copy_to_writer():

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.

Could we please add an assertion here?

@larsga

larsga commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

As they have been exposed as public API, we unfortunately need to keep this backwards-compatible with a proper deprecation period and cannot simply remove them. Please indicate if you need help with this, especially with the init.py part.

@stefan6419846 Yes, please. I don't know the deprecation process for PyPDF, so I'm at a loss for how to proceed here.

@larsga
larsga force-pushed the issue-3290-part-2 branch from ecc1d1c to a9da8f6 Compare June 16, 2026 08:19
@stefan6419846

Copy link
Copy Markdown
Collaborator

Yes, please. I don't know the deprecation process for PyPDF, so I'm at a loss for how to proceed here.

I will try to look into this as fast as possible, but for personal reasons, it might take a few weeks.

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.

2 participants