Skip to content

Commit 8f2ce99

Browse files
committed
Merge remote-tracking branch 'py-pdf/main' into Common2
2 parents 40c6666 + 0106904 commit 8f2ce99

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

pypdf/_reader.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class PdfReader(PdfDocCommon):
119119
Defaults to ``False``.
120120
password: Decrypt PDF file at initialization. If the
121121
password is None, the file will not be decrypted.
122-
Defaults to ``None``
122+
Defaults to ``None``.
123123
"""
124124

125125
def __init__(
@@ -251,9 +251,9 @@ def metadata(self) -> Optional[DocumentInformation]:
251251
"""
252252
Retrieve the PDF file's document information dictionary, if it exists.
253253
254-
Note that some PDF files use metadata streams instead of docinfo
255-
dictionaries, and these metadata streams will not be accessed by this
256-
function.
254+
Note that some PDF files use metadata streams instead of document
255+
information dictionaries, and these metadata streams will not be
256+
accessed by this function.
257257
"""
258258
if TK.INFO not in self.trailer:
259259
return None
@@ -279,7 +279,7 @@ def _get_num_pages(self) -> int:
279279
Calculate the number of pages in this PDF file.
280280
281281
Returns:
282-
The number of pages of the parsed PDF file
282+
The number of pages of the parsed PDF file.
283283
284284
Raises:
285285
PdfReadError: if file is encrypted and restrictions prevent
@@ -337,7 +337,7 @@ def get_fields(
337337
tree:
338338
retval:
339339
fileobj: A file object (usually a text file) to write
340-
a report to on all interactive form fields found.
340+
a report of all interactive form fields found.
341341
342342
Returns:
343343
A dictionary where each key is a field name, and each
@@ -476,7 +476,7 @@ def get_form_text_fields(self, full_qualified_name: bool = False) -> Dict[str, A
476476
Retrieve form fields from the document with textual data.
477477
478478
Args:
479-
full_qualified_name: to get full name
479+
full_qualified_name: to get full name.
480480
481481
Returns:
482482
A dictionary. The key is the name of the form field,
@@ -516,7 +516,7 @@ def get_pages_showing_field(
516516
Provides list of pages where the field is called.
517517
518518
Args:
519-
field: Field Object, PdfObject or IndirectObject referencing a Field
519+
field: Field Object, PdfObject or IndirectObject referencing a Field.
520520
521521
Returns:
522522
list of pages:
@@ -712,9 +712,9 @@ def threads(self) -> Optional[ArrayObject]:
712712
"""
713713
Read-only property for the list of threads.
714714
715-
See §8.3.2 from PDF 1.7 spec.
715+
See §12.4.3 of the PDF 1.7 or PDF 2.0 specification.
716716
717-
It's an array of dictionaries with "/F" and "/I" properties or
717+
An array of dictionaries with "/F" and "/I" properties or
718718
None if there are no articles.
719719
"""
720720
catalog = self.root_object

pypdf/_writer.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def _rolling_checksum(stream: BytesIO, blocksize: int = 65536) -> str:
148148

149149
class PdfWriter(PdfDocCommon):
150150
"""
151-
Write a PDF file out, given pages produced by another class.
151+
Write a PDF file out, given pages produced by another class or through
152+
cloning a PDF file during initialization.
152153
153154
Typically data is added from a :class:`PdfReader<pypdf.PdfReader>`.
154155
"""
@@ -225,10 +226,10 @@ def __init__(
225226
@property
226227
def root_object(self) -> DictionaryObject:
227228
"""
228-
Provide direct access to Pdf Structure
229+
Provide direct access to Pdf Structure.
229230
230231
Note:
231-
Recommended be used only for read access
232+
Recommended be used only for read access.
232233
"""
233234
return self._root_object
234235

@@ -408,7 +409,7 @@ def set_need_appearances_writer(self, state: bool = True) -> None:
408409
None
409410
"""
410411
# See 12.7.2 and 7.7.2 for more information:
411-
# http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
412+
# https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf
412413
try:
413414
# get the AcroForm tree
414415
if CatalogDictionary.ACRO_FORM not in self._root_object:
@@ -499,7 +500,7 @@ def add_blank_page(
499500
self, width: Optional[float] = None, height: Optional[float] = None
500501
) -> PageObject:
501502
"""
502-
Append a blank page to this PDF file and returns it.
503+
Append a blank page to this PDF file and return it.
503504
504505
If no page size is specified, use the size of the last page.
505506
@@ -526,7 +527,7 @@ def insert_blank_page(
526527
index: int = 0,
527528
) -> PageObject:
528529
"""
529-
Insert a blank page to this PDF file and returns it.
530+
Insert a blank page to this PDF file and return it.
530531
531532
If no page size is specified, use the size of the last page.
532533
@@ -538,7 +539,7 @@ def insert_blank_page(
538539
index: Position to add the page.
539540
540541
Returns:
541-
The newly appended page
542+
The newly appended page.
542543
543544
Raises:
544545
PageSizeNotDefinedError: if width and height are not defined
@@ -580,7 +581,7 @@ def open_destination(self, dest: Union[None, str, Destination, PageObject]) -> N
580581

581582
def add_js(self, javascript: str) -> None:
582583
"""
583-
Add Javascript which will launch upon opening this PDF.
584+
Add JavaScript which will launch upon opening this PDF.
584585
585586
Args:
586587
javascript: Your Javascript.
@@ -618,7 +619,7 @@ def add_attachment(self, filename: str, data: Union[str, bytes]) -> None:
618619
Embed a file inside the PDF.
619620
620621
Reference:
621-
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
622+
https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf
622623
Section 7.11.3
623624
624625
Args:
@@ -715,7 +716,7 @@ def append_pages_from_reader(
715716
Args:
716717
reader: a PdfReader object from which to copy page
717718
annotations to this writer object. The writer's annots
718-
will then be updated
719+
will then be updated.
719720
after_page_append:
720721
Callback function that is invoked after each page is appended to
721722
the writer. Signature includes a reference to the appended page
@@ -878,12 +879,12 @@ def update_page_form_field_values(
878879
page: Page reference from PDF writer where the
879880
annotations and field data will be updated.
880881
fields: a Python dictionary of field names (/T) and text
881-
values (/V)
882+
values (/V).
882883
flags: An integer (0 to 7). The first bit sets ReadOnly, the
883884
second bit sets Required, the third bit sets NoExport. See
884885
PDF Reference Table 8.70 for details.
885886
auto_regenerate: set/unset the need_appearances flag ;
886-
the flag is unchanged if auto_regenerate is None
887+
the flag is unchanged if auto_regenerate is None.
887888
"""
888889
if CatalogDictionary.ACRO_FORM not in self._root_object:
889890
raise PyPdfError("No /AcroForm dictionary in PdfWriter Object")
@@ -957,13 +958,14 @@ def reattach_fields(
957958
) -> List[DictionaryObject]:
958959
"""
959960
Parse annotations within the page looking for orphan fields and
960-
reattach then into the Fields Structure
961+
reattach then into the Fields Structure.
961962
962963
Args:
963964
page: page to analyze.
964-
If none is provided, all pages will be analyzed
965+
If none is provided, all pages will be analyzed.
966+
965967
Returns:
966-
list of reattached fields
968+
list of reattached fields.
967969
"""
968970
lst = []
969971
if page is None:
@@ -1068,7 +1070,7 @@ def generate_file_identifiers(self) -> None:
10681070
Generate an identifier for the PDF that will be written.
10691071
10701072
The only point of this is ensuring uniqueness. Reproducibility is not
1071-
required;
1073+
required.
10721074
When a file is first written, both identifiers shall be set to the same value.
10731075
If both identifiers match when a file reference is resolved, it is very
10741076
likely that the correct and unchanged file has been found. If only the first
@@ -1111,8 +1113,8 @@ def encrypt(
11111113
Bit position 3 is for printing, 4 is for modifying content,
11121114
5 and 6 control annotations, 9 for form fields,
11131115
10 for extraction of text and graphics.
1114-
algorithm: encrypt algorithm. Values maybe one of "RC4-40", "RC4-128",
1115-
"AES-128", "AES-256-R5", "AES-256". If it's valid,
1116+
algorithm: encrypt algorithm. Values may be one of "RC4-40", "RC4-128",
1117+
"AES-128", "AES-256-R5", "AES-256". If it is valid,
11161118
`use_128bit` will be ignored.
11171119
"""
11181120
if owner_password is None:
@@ -1163,7 +1165,7 @@ def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO[Any]]:
11631165
Write the collection of pages added to this object out as a PDF file.
11641166
11651167
Args:
1166-
stream: An object to write the file to. The object can support
1168+
stream: An object to write the file to. The object can support
11671169
the write method and the tell method, similar to a file object, or
11681170
be a file path, just like the fileobj, just named it stream to keep
11691171
existing workflow.
@@ -1435,7 +1437,7 @@ def get_threads_root(self) -> ArrayObject:
14351437
"""
14361438
The list of threads.
14371439
1438-
See §8.3.2 from PDF 1.7 spec.
1440+
See §12.4.3 of the PDF 1.7 or PDF 2.0 specification.
14391441
14401442
Returns:
14411443
An array (possibly empty) of Dictionaries with ``/F`` and

0 commit comments

Comments
 (0)