Skip to content
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

Watermarking pdf: copy TOC/outline from source to destination #1902

Closed
philipaxer opened this issue Jun 21, 2023 · 4 comments
Closed

Watermarking pdf: copy TOC/outline from source to destination #1902

philipaxer opened this issue Jun 21, 2023 · 4 comments
Assignees
Labels
Easy This issue is a good starting point for first-time contributors nf-documentation Non-functional change: Documentation

Comments

@philipaxer
Copy link

Explanation

The documentation gives an example how to watermark a pdf. While this works, the outlines of the original PDF is lost. Usually technical documenation is watermarked and the outlines are quite helpful to navigate the document. How can i carry over the outline from the source PDF to the destination?

@pubpub-zz
Copy link
Collaborator

you should be able to first load (using clone_from= within the PdfWriter constructor) your pdf file or using .append().
Within the PdfWriter you should be able to loop through the page and use https://pypdf.readthedocs.io/en/stable/modules/PageObject.html#pypdf._page.PageObject.merge_page to apply the watermark.
Can you test this approach?

@philipaxer
Copy link
Author

Hi, thanks for the suggestion. That has worked nicely, all meta data is carried over.

@pubpub-zz
Copy link
Collaborator

Would you be ok to propose a PR to update the documentation to present the solution?

@py-pdf py-pdf deleted a comment from pubpub-zz Jun 30, 2023
@MartinThoma MartinThoma added nf-documentation Non-functional change: Documentation Easy This issue is a good starting point for first-time contributors labels Jun 30, 2023
@pubpub-zz
Copy link
Collaborator

#1952 has updated the documentation. we can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy This issue is a good starting point for first-time contributors nf-documentation Non-functional change: Documentation
Projects
None yet
Development

No branches or pull requests

3 participants