From 3c4fa509c5957336a9733ad45d9bfd1f2a08ae44 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 11 Oct 2022 12:17:09 +0200 Subject: [PATCH] Fix object referenced in parent tree --- weasyprint/pdf/pdfua.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/weasyprint/pdf/pdfua.py b/weasyprint/pdf/pdfua.py index e36e92ed4d..3f19c70a27 100644 --- a/weasyprint/pdf/pdfua.py +++ b/weasyprint/pdf/pdfua.py @@ -41,12 +41,13 @@ def pdfua(pdf, metadata, document, page_streams): # Build structure elements kids = [mcid] if key == 'Link': - reference = pydyf.Dictionary({ + object_reference = pydyf.Dictionary({ 'Type': '/OBJR', 'Obj': box.link_annotation.reference, + 'Pg': pdf.pages['Kids'][page_number], }) - pdf.add_object(reference) - kids.append(reference.reference) + pdf.add_object(object_reference) + links.append((object_reference.reference, box.link_annotation)) etree_element = box.element child_structure_data_element = None while True: @@ -93,8 +94,6 @@ def pdfua(pdf, metadata, document, page_streams): if isinstance(kid, int): parents[kid] = child.reference kid = child.reference - if key == 'Link': - links.append((kid, box.link_annotation)) if child_structure_data_element is not None: child_structure_data_element['P'] = kid if not new_element: