Skip to content

Commit 70139de

Browse files
Merge pull request #175 from chinapandaman/PPF-174
PPF-174: update docs with read method
2 parents 74d287a + f6af4ce commit 70139de

15 files changed

+30
-26
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
4848
)
4949

5050
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
51-
output.write(filled_pdf.stream)
51+
output.write(filled_pdf.read())
5252
```
5353

5454
After running the above code snippet you can find `output.pdf` at the location you specified,

docs/v2/api_reference.md

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ Its values currently support the following:
126126
* **editable** - only available if `simple_mode` is `True`, enabling this will allow the filled PDF to be still
127127
editable. NOTE: `image` elements that are filled via the `fill` method will NOT be editable even if this is `True`.
128128

129+
### **read**()
130+
131+
Returns the `stream`. This method allows the implementation of PyPDFForm to behave like a file object.
132+
129133
### **register_font**(*font_name, ttf_stream*)
130134

131135
This class method takes a TTF font file stream and register it with the `font_name` specified.

docs/v2/examples.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
4545
)
4646

4747
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
48-
output.write(filled_pdf.stream)
48+
output.write(filled_pdf.read())
4949
```
5050

5151
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/simple_fill.py
@@ -81,7 +81,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
8181
)
8282

8383
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
84-
output.write(filled_pdf.stream)
84+
output.write(filled_pdf.read())
8585
```
8686

8787
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/simple_fill_editable.py
@@ -126,7 +126,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
126126
)
127127

128128
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
129-
output.write(filled_pdf.stream)
129+
output.write(filled_pdf.read())
130130
```
131131

132132
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_font.py
@@ -167,7 +167,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
167167
)
168168

169169
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
170-
output.write(filled_pdf.stream)
170+
output.write(filled_pdf.read())
171171
```
172172

173173
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_global_font_size_color.py
@@ -205,7 +205,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
205205
)
206206

207207
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
208-
output.write(filled_pdf.stream)
208+
output.write(filled_pdf.read())
209209
```
210210

211211
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_text_wrap.py
@@ -246,7 +246,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
246246
)
247247

248248
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
249-
output.write(filled_pdf.stream)
249+
output.write(filled_pdf.read())
250250
```
251251

252252
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_text_offset.py
@@ -274,7 +274,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
274274
filled_pdf = PyPDFForm(template.read()).draw_text("drawn_text", 1, 300, 225)
275275

276276
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
277-
output.write(filled_pdf.stream)
277+
output.write(filled_pdf.read())
278278
```
279279

280280
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/draw_text.py
@@ -307,7 +307,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
307307
)
308308

309309
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
310-
output.write(filled_pdf.stream)
310+
output.write(filled_pdf.read())
311311
```
312312

313313
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/draw_image.py
@@ -345,7 +345,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
345345
)
346346

347347
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
348-
output.write(filled_pdf.stream)
348+
output.write(filled_pdf.read())
349349
```
350350

351351
Alternatively you can use the assignment operator to achieve the same.
@@ -379,7 +379,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
379379
)
380380

381381
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
382-
output.write(filled_pdf.stream)
382+
output.write(filled_pdf.read())
383383
```
384384

385385
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/merge.py
@@ -435,7 +435,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
435435
)
436436

437437
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
438-
output.write(pdf_form.stream)
438+
output.write(pdf_form.read())
439439
```
440440

441441
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_customized_elements.py
@@ -469,7 +469,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
469469
)
470470

471471
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
472-
output.write(filled_pdf.stream)
472+
output.write(filled_pdf.read())
473473
```
474474

475475
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/simple_fill_radio.py
@@ -528,7 +528,7 @@ with open(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM, "rb+") as template:
528528
)
529529

530530
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
531-
output.write(filled_pdf.stream)
531+
output.write(filled_pdf.read())
532532
```
533533

534534
Link to this example: https://github.com/chinapandaman/PyPDFForm/blob/master/examples/fill_images.py

examples/draw_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
)
2222

2323
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
24-
output.write(filled_pdf.stream)
24+
output.write(filled_pdf.read())

examples/draw_text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
filled_pdf = PyPDFForm(template.read()).draw_text("drawn_text", 1, 300, 225)
1515

1616
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
17-
output.write(filled_pdf.stream)
17+
output.write(filled_pdf.read())

examples/fill_customized_elements.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
)
4343

4444
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
45-
output.write(pdf_form.stream)
45+
output.write(pdf_form.read())

examples/fill_font.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
)
3535

3636
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
37-
output.write(filled_pdf.stream)
37+
output.write(filled_pdf.read())

examples/fill_global_font_size_color.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
)
2929

3030
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
31-
output.write(filled_pdf.stream)
31+
output.write(filled_pdf.read())

examples/fill_images.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
)
4242

4343
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
44-
output.write(filled_pdf.stream)
44+
output.write(filled_pdf.read())

examples/fill_text_offset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
)
2929

3030
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
31-
output.write(filled_pdf.stream)
31+
output.write(filled_pdf.read())

examples/fill_text_wrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
)
2828

2929
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
30-
output.write(filled_pdf.stream)
30+
output.write(filled_pdf.read())

examples/merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
)
2727

2828
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
29-
output.write(filled_pdf.stream)
29+
output.write(filled_pdf.read())

examples/simple_fill.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
)
2424

2525
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
26-
output.write(filled_pdf.stream)
26+
output.write(filled_pdf.read())

examples/simple_fill_editable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
)
2525

2626
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
27-
output.write(filled_pdf.stream)
27+
output.write(filled_pdf.read())

examples/simple_fill_radio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
)
2121

2222
with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
23-
output.write(filled_pdf.stream)
23+
output.write(filled_pdf.read())

0 commit comments

Comments
 (0)