@@ -215,14 +215,12 @@ with open("annotated-pdf.pdf", "wb") as fp:
215
215
216
216
## Popup
217
217
218
- Manage the Popup windows for markups. looks like this:
218
+ Manage the Popup windows for markups, looks like this:
219
219
220
220
![ ] ( annotation-popup.png )
221
221
222
222
you can use the {py: class }` Popup <pypdf.annotations.Popup> ` :
223
223
224
- you have to use the returned result from add_annotation() to fill-up the
225
-
226
224
``` python
227
225
from pypdf.annotations import Popup, Text
228
226
@@ -249,6 +247,9 @@ popup_annotation = Popup(
249
247
writer.write(" annotated-pdf-popup.pdf" )
250
248
```
251
249
250
+ You have to use the returned result from add_annotation() as it is
251
+ the parent annotation with which this popup annotation shall be associated.
252
+
252
253
## Link
253
254
254
255
If you want to add a link, you can use
@@ -264,7 +265,7 @@ page = reader.pages[0]
264
265
writer = PdfWriter()
265
266
writer.add_page(page)
266
267
267
- # Add the line
268
+ # Add the link
268
269
annotation = Link(
269
270
rect = (50 , 550 , 200 , 650 ),
270
271
url = " https://martin-thoma.com/" ,
@@ -281,16 +282,19 @@ You can also add internal links:
281
282
``` python
282
283
from pypdf import PdfReader, PdfWriter
283
284
from pypdf.annotations import Link
285
+ from pypdf.generic import Fit
284
286
285
287
pdf_path = os.path.join(RESOURCE_ROOT , " crazyones.pdf" )
286
288
reader = PdfReader(pdf_path)
287
289
page = reader.pages[0 ]
288
290
writer = PdfWriter()
289
291
writer.add_page(page)
290
292
291
- # Add the line
293
+ # Add the link
292
294
annotation = Link(
293
- 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 ,)),
294
298
)
295
299
writer.add_annotation(page_number = 0 , annotation = annotation)
296
300
@@ -303,7 +307,7 @@ with open("annotated-pdf.pdf", "wb") as fp:
303
307
304
308
Text markup annotations refer to a specific piece of text within the document.
305
309
306
- Those are a bit more complicated as you need to know exactly where the text
310
+ These are a bit more complicated as you need to know exactly where the text
307
311
is, the so-called "Quad points".
308
312
309
313
### Highlighting
0 commit comments