From d42fc8425f28fc3ae4446cc6fac528ac51bd0e46 Mon Sep 17 00:00:00 2001 From: Jonathan Parris Date: Wed, 17 Jul 2024 15:53:41 -0600 Subject: [PATCH] BUG: Updating Link Documentation Example (#2751) --- docs/user/adding-pdf-annotations.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/user/adding-pdf-annotations.md b/docs/user/adding-pdf-annotations.md index 6d61affcf..083d6ccd8 100644 --- a/docs/user/adding-pdf-annotations.md +++ b/docs/user/adding-pdf-annotations.md @@ -265,7 +265,7 @@ page = reader.pages[0] writer = PdfWriter() writer.add_page(page) -# Add the line +# Add the link annotation = Link( rect=(50, 550, 200, 650), url="https://martin-thoma.com/", @@ -282,6 +282,7 @@ You can also add internal links: ```python from pypdf import PdfReader, PdfWriter from pypdf.annotations import Link +from pypdf.generic import Fit pdf_path = os.path.join(RESOURCE_ROOT, "crazyones.pdf") reader = PdfReader(pdf_path) @@ -289,9 +290,11 @@ page = reader.pages[0] writer = PdfWriter() writer.add_page(page) -# Add the line +# Add the link annotation = Link( - rect=(50, 550, 200, 650), target_page_index=3, fit="/FitH", fit_args=(123,) + rect=(50, 550, 200, 650), + target_page_index=3, + fit=Fit(fit_type="/FitH", fit_args=(123,)), ) writer.add_annotation(page_number=0, annotation=annotation)