Skip to content

Commit

Permalink
Merge pull request #526 from chinapandaman/PPF-524
Browse files Browse the repository at this point in the history
PPF-524: simple fill docs
  • Loading branch information
chinapandaman authored Mar 17, 2024
2 parents 91d3bc9 + 148133f commit cd24101
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ It also supports other common utilities such as extracting pages and merging mul
* [Prepare a PDF form](prepare.md)
* [Inspect a PDF form](inspect.md)
* [Fill a PDF form](fill.md)
* [Fill a PDF form in place (beta)](simple_fill.md)
* [Change text field styles](style.md)
* [Change checkbox and radio button styles](button_style.md)
* [Draw stuffs](draw.md)
Expand Down
4 changes: 4 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pip install -U PyPDFForm

## Create a PDF wrapper

There are two classes provided by the library that abstract a PDF form. The `FormWrapper` class allows you to fill a
PDF form if you don't need any other API. More info about `FormWrapper` can be found
[here](simple_fill.md).

The class that implements most of PyPDFForm's APIs is `PdfWrapper`. It takes various optional parameters to instantiate,
with the most important one being the PDF form "template".

Expand Down
32 changes: 32 additions & 0 deletions docs/simple_fill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Fill a PDF form in place (beta)

**NOTE:** This page contains beta features, meaning it's known that these features do not support some PDF forms but
currently there are no plans and/or solutions to fix them.

The `FormWrapper` class allows you to fill a PDF form in place as if you were filling it manually. The resulted filled
PDF form will NOT be flattened and will still be editable.

Similar to the `PdfWrapper` class, the `FormWrapper` also supports widgets including text fields, checkboxes, radio
buttons, dropdowns, and paragraphs. However, it does NOT support signature widgets.

Consider [this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/dropdown/sample_template_with_dropdown.pdf):

```python
from PyPDFForm import FormWrapper

filled = FormWrapper("sample_template_with_dropdown.pdf").fill(
{
"test_1": "test_1",
"test_2": "test_2",
"test_3": "test_3",
"check_1": True,
"check_2": True,
"check_3": True,
"radio_1": 1,
"dropdown_1": 1,
},
)

with open("output.pdf", "wb+") as output:
output.write(filled.read())
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ nav:
- prepare.md
- inspect.md
- fill.md
- simple_fill.md
- style.md
- button_style.md
- draw.md
Expand Down

0 comments on commit cd24101

Please sign in to comment.