Skip to content

Commit

Permalink
BUG: - Updating Link Documentation Example (#2751)
Browse files Browse the repository at this point in the history
  • Loading branch information
jparris committed Jul 17, 2024
1 parent 5f57d1f commit 762eaf3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/user/adding-pdf-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -282,16 +282,19 @@ 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)
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)

Expand Down

0 comments on commit 762eaf3

Please sign in to comment.