@@ -148,7 +148,8 @@ def _rolling_checksum(stream: BytesIO, blocksize: int = 65536) -> str:
148
148
149
149
class PdfWriter (PdfDocCommon ):
150
150
"""
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.
152
153
153
154
Typically data is added from a :class:`PdfReader<pypdf.PdfReader>`.
154
155
"""
@@ -225,10 +226,10 @@ def __init__(
225
226
@property
226
227
def root_object (self ) -> DictionaryObject :
227
228
"""
228
- Provide direct access to Pdf Structure
229
+ Provide direct access to Pdf Structure.
229
230
230
231
Note:
231
- Recommended be used only for read access
232
+ Recommended be used only for read access.
232
233
"""
233
234
return self ._root_object
234
235
@@ -408,7 +409,7 @@ def set_need_appearances_writer(self, state: bool = True) -> None:
408
409
None
409
410
"""
410
411
# 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
412
413
try :
413
414
# get the AcroForm tree
414
415
if CatalogDictionary .ACRO_FORM not in self ._root_object :
@@ -499,7 +500,7 @@ def add_blank_page(
499
500
self , width : Optional [float ] = None , height : Optional [float ] = None
500
501
) -> PageObject :
501
502
"""
502
- Append a blank page to this PDF file and returns it.
503
+ Append a blank page to this PDF file and return it.
503
504
504
505
If no page size is specified, use the size of the last page.
505
506
@@ -526,7 +527,7 @@ def insert_blank_page(
526
527
index : int = 0 ,
527
528
) -> PageObject :
528
529
"""
529
- Insert a blank page to this PDF file and returns it.
530
+ Insert a blank page to this PDF file and return it.
530
531
531
532
If no page size is specified, use the size of the last page.
532
533
@@ -538,7 +539,7 @@ def insert_blank_page(
538
539
index: Position to add the page.
539
540
540
541
Returns:
541
- The newly appended page
542
+ The newly appended page.
542
543
543
544
Raises:
544
545
PageSizeNotDefinedError: if width and height are not defined
@@ -580,7 +581,7 @@ def open_destination(self, dest: Union[None, str, Destination, PageObject]) -> N
580
581
581
582
def add_js (self , javascript : str ) -> None :
582
583
"""
583
- Add Javascript which will launch upon opening this PDF.
584
+ Add JavaScript which will launch upon opening this PDF.
584
585
585
586
Args:
586
587
javascript: Your Javascript.
@@ -618,7 +619,7 @@ def add_attachment(self, filename: str, data: Union[str, bytes]) -> None:
618
619
Embed a file inside the PDF.
619
620
620
621
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
622
623
Section 7.11.3
623
624
624
625
Args:
@@ -715,7 +716,7 @@ def append_pages_from_reader(
715
716
Args:
716
717
reader: a PdfReader object from which to copy page
717
718
annotations to this writer object. The writer's annots
718
- will then be updated
719
+ will then be updated.
719
720
after_page_append:
720
721
Callback function that is invoked after each page is appended to
721
722
the writer. Signature includes a reference to the appended page
@@ -878,12 +879,12 @@ def update_page_form_field_values(
878
879
page: Page reference from PDF writer where the
879
880
annotations and field data will be updated.
880
881
fields: a Python dictionary of field names (/T) and text
881
- values (/V)
882
+ values (/V).
882
883
flags: An integer (0 to 7). The first bit sets ReadOnly, the
883
884
second bit sets Required, the third bit sets NoExport. See
884
885
PDF Reference Table 8.70 for details.
885
886
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.
887
888
"""
888
889
if CatalogDictionary .ACRO_FORM not in self ._root_object :
889
890
raise PyPdfError ("No /AcroForm dictionary in PdfWriter Object" )
@@ -957,13 +958,14 @@ def reattach_fields(
957
958
) -> List [DictionaryObject ]:
958
959
"""
959
960
Parse annotations within the page looking for orphan fields and
960
- reattach then into the Fields Structure
961
+ reattach then into the Fields Structure.
961
962
962
963
Args:
963
964
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
+
965
967
Returns:
966
- list of reattached fields
968
+ list of reattached fields.
967
969
"""
968
970
lst = []
969
971
if page is None :
@@ -1068,7 +1070,7 @@ def generate_file_identifiers(self) -> None:
1068
1070
Generate an identifier for the PDF that will be written.
1069
1071
1070
1072
The only point of this is ensuring uniqueness. Reproducibility is not
1071
- required;
1073
+ required.
1072
1074
When a file is first written, both identifiers shall be set to the same value.
1073
1075
If both identifiers match when a file reference is resolved, it is very
1074
1076
likely that the correct and unchanged file has been found. If only the first
@@ -1111,8 +1113,8 @@ def encrypt(
1111
1113
Bit position 3 is for printing, 4 is for modifying content,
1112
1114
5 and 6 control annotations, 9 for form fields,
1113
1115
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,
1116
1118
`use_128bit` will be ignored.
1117
1119
"""
1118
1120
if owner_password is None :
@@ -1163,7 +1165,7 @@ def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO[Any]]:
1163
1165
Write the collection of pages added to this object out as a PDF file.
1164
1166
1165
1167
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
1167
1169
the write method and the tell method, similar to a file object, or
1168
1170
be a file path, just like the fileobj, just named it stream to keep
1169
1171
existing workflow.
@@ -1435,7 +1437,7 @@ def get_threads_root(self) -> ArrayObject:
1435
1437
"""
1436
1438
The list of threads.
1437
1439
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 .
1439
1441
1440
1442
Returns:
1441
1443
An array (possibly empty) of Dictionaries with ``/F`` and
0 commit comments