Skip to content

Commit fe33cf6

Browse files
authored
DOC: Update Link Documentation Example (#2759)
Closes #2751.
1 parent 5f57d1f commit fe33cf6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/user/adding-pdf-annotations.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ page = reader.pages[0]
265265
writer = PdfWriter()
266266
writer.add_page(page)
267267

268-
# Add the line
268+
# Add the link
269269
annotation = Link(
270270
rect=(50, 550, 200, 650),
271271
url="https://martin-thoma.com/",
@@ -282,16 +282,19 @@ You can also add internal links:
282282
```python
283283
from pypdf import PdfReader, PdfWriter
284284
from pypdf.annotations import Link
285+
from pypdf.generic import Fit
285286

286287
pdf_path = os.path.join(RESOURCE_ROOT, "crazyones.pdf")
287288
reader = PdfReader(pdf_path)
288289
page = reader.pages[0]
289290
writer = PdfWriter()
290291
writer.add_page(page)
291292

292-
# Add the line
293+
# Add the link
293294
annotation = Link(
294-
rect=(50, 550, 200, 650), target_page_index=3, fit="/FitH", fit_args=(123,)
295+
rect=(50, 550, 200, 650),
296+
target_page_index=3,
297+
fit=Fit(fit_type="/FitH", fit_args=(123,)),
295298
)
296299
writer.add_annotation(page_number=0, annotation=annotation)
297300

0 commit comments

Comments
 (0)