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

annotations are lost with PDFDocumentCopyingContext::AppendPDFPageFromPDF #219

Closed
jacques-quidu opened this issue Jul 12, 2023 · 3 comments

Comments

@jacques-quidu
Copy link

jacques-quidu commented Jul 12, 2023

annotations are lost while appending pages with PDFDocumentCopyingContext::AppendPDFPageFromPDF:
it seems like DocumentContext::mAnnotations is not feed from source page to document context before writing the page to destination ?

Note that this issue is not reproducible with PDFWriter::ModifyPDF: it is only reproducible while using a PDFDocumentCopyingContext from a source file or stream returned by PDFWriter::CreatePDFCopyingContext and then append pages from this source context.

i guess it would need for AppendPDFPageFromPDF to copy annotations from source page to DocumentContext::mAnnotations in append pages code before calling write page method because the write page method code assumes annotations to write for page are stored in DocumentContext::mAnnotations.

@galkahana
Copy link
Owner

the basic copy operation copies only the pages and their graphic context, nothing global (and annotations are defined globally). that works as intended. if you do care about annotations, you can extend the copying activity to copy them to.
i wrote a post about this once:
https://www.pdfhummus.com/post/45501619928/copying-pages-with-comments
and here's some sample code:
https://github.com/galkahana/PDFWriterSamples/blob/master/CopyingPagesWithComments/CopyingPagesWithComments.cpp

@jacques-quidu
Copy link
Author

Ok thanks for the explanation and sample.

@jacques-quidu
Copy link
Author

actually i wrongly thought that because annotations are referenced in pdf page with /Annots that it should be copied too while copying pages but my mistake so: thanks again.

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

No branches or pull requests

2 participants