Skip to content

Commit 32f826b

Browse files
authored
DOC: Slightly improve wording and three examples (#2634)
* DOC: Slightly improve wording and three examples * DOC: Slightly improve wording and three examples * DOC: Slightly improve wording and three examples * DOC: Slightly improve wording and three examples Also change get_pages_using_field to get_pages_showing_field. * DOC: Slightly improve wording and three examples Revert wording back to "id est".
1 parent a435eaa commit 32f826b

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

docs/user/extract-text.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ parts = []
8585

8686
def visitor_body(text, cm, tm, font_dict, font_size):
8787
y = cm[5]
88-
if y > 50 and y < 720:
88+
if 50 < y < 720:
8989
parts.append(text)
9090

9191

docs/user/forms.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ writer.update_page_form_field_values(
3232
auto_regenerate=False,
3333
)
3434

35-
# write "output" to pypdf-output.pdf
3635
with open("filled-out.pdf", "wb") as output_stream:
3736
writer.write(output_stream)
3837
```
@@ -94,14 +93,14 @@ for page in reader.pages:
9493

9594
However, while similar, there are some very important differences between the two above blocks of code. Most importantly, the first block will return a list of Field objects, whereas the second will return more generic dictionary-like objects. The objects lists will *mostly* reference the same object in the underlying PDF, meaning you'll find that `obj_taken_fom_first_list.indirect_reference == obj_taken_from _second_list.indirect_reference`. Field objects are generally more ergonomic, as the exposed data can be accessed via clearly named properties. However, the more generic dictionary-like objects will contain data that the Field object does not expose, such as the Rect (the widget's position on the page). Therefore the correct approach depends on your use case.
9695

97-
However, it's also important to note that the two lists do not *always* refer to the same underlying PDF object. For example, if the form contains radio buttons, you will find that `reader.get_fields()` will get the parent object (the group of radio buttons) whereas `page.annotations` will return all the child objects (the individual radio buttons).
96+
However, it is also important to note that the two lists do not *always* refer to the same underlying PDF object. For example, if the form contains radio buttons, you will find that `reader.get_fields()` will get the parent object (the group of radio buttons) whereas `page.annotations` will return all the child objects (the individual radio buttons).
9897

99-
__Caution: Remember that fields are not stored in pages: If you use `add_page()` the field structure is not copied. It is recommended to use `.append()` with the proper parameters instead.__
98+
__Caution: Remember that fields are not stored in pages; if you use `add_page()` the field structure is not copied. It is recommended to use `.append()` with the proper parameters instead.__
10099

101-
In case of missing _field_ objects in `/Fields`, `writer.reattach_fields()` will parse page(s) annotations and will reattach them. This fix can not guess intermediate fields and will not report fields using the same _name_.
100+
In case of missing _field_ objects in `/Fields`, `writer.reattach_fields()` will parse page(s) annotations and will reattach them. This fix cannot guess intermediate fields and will not report fields using the same _name_.
102101

103102
## Identify pages where fields are used
104103

105-
On order to ease locating page fields you can use `page.get_pages_using_field`. This methods accepts a field object, id est a *PdfObject* that represents a field (as are extracted from `_root_object["/AcroForm"]["/Fields"]`. The method returns a list of pages, because a field can have multiple widgets as mentioned previously (e.g. radio buttons or text displayed on multiple pages).
104+
In order to ease locating page fields you can use `get_pages_showing_field` of PdfReader or PdfWriter. This method accepts a field object, a *PdfObject* that represents a field (as extracted from `_root_object["/AcroForm"]["/Fields"]`). The method returns a list of pages, because a field can have multiple widgets as mentioned previously (e.g. radio buttons or text displayed on multiple pages).
106105

107106
The page numbers can then be retrieved as usual by using `page.page_number`.

docs/user/merging-pdfs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ If you want to insert pages in the middle of the destination, use `merge` (which
6767
You can insert the same page multiple times, if necessary even using a list-based syntax:
6868

6969
```python
70+
# Insert pages 2 and 3, with page 1 before, between, and after
7071
writer.append(reader, [0, 1, 0, 2, 0])
7172
```
72-
will insert the pages 1 and 2 with page 0 before, in the middle and after.
7373

7474
## add_page / insert_page
7575

docs/user/viewer-preferences.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ It is possible to set viewer preferences of a PDF file.
44
These properties are described in Section 12.2 of the [PDF 1.7 specification](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf).
55

66
Note that the `/ViewerPreferences` dictionary does not exist by default.
7-
If it's not already present, it must be created by calling the `create_viewer_preferences` method
7+
If it is not already present, it must be created by calling the `create_viewer_preferences` method
88
of the `PdfWriter` object.
99

1010
If viewer preferences exist in a PDF file being read with `PdfReader`,
@@ -79,5 +79,5 @@ with open("output.pdf", "wb") as output_stream:
7979
```
8080

8181
The names beginning with a slash character are part of the PDF file format. They are
82-
included here to aid to anyone searching pypdf documentation
82+
included here to ease searching the pypdf documentation
8383
for these names from the PDF specification.

0 commit comments

Comments
 (0)