Skip to content

Commit

Permalink
Fix error with annotations on duplicated pages
Browse files Browse the repository at this point in the history
Ensure duplicated pages receive a copy of the annotations, not a reference
Fixes pdfarranger#437
  • Loading branch information
m-holger committed Mar 29, 2021
1 parent b97c8d8 commit 96f1b3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pdfarranger/exporter.py
Expand Up @@ -171,6 +171,12 @@ def export(input_files, pages, file_out, mode, mdata):
new_page = pdf_output.make_indirect(new_page)

pdf_output.pages.append(new_page)
# Ensure annotations are copied rather than referenced
# https://github.com/pdfarranger/pdfarranger/issues/437
if pikepdf.Name.Annots in current_page:
pdf_temp = pikepdf.Pdf.new()
pdf_temp.pages.append(current_page)
pdf_output.pages[-1].Annots = pdf_output.copy_foreign(pdf_temp.pages[0].Annots)

if exportmode in ['ALL_TO_MULTIPLE', 'SELECTED_TO_MULTIPLE']:
for n, page in enumerate(pdf_output.pages):
Expand Down

0 comments on commit 96f1b3a

Please sign in to comment.