-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #518 from chinapandaman/PPF-517
PPF-517: support change checkbox/radio button size and button style
- Loading branch information
Showing
12 changed files
with
153 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[MESSAGES CONTROL] | ||
disable=C0103, R0913, R0902, R0903, R0914, C0209 | ||
disable=C0103, R0913, R0902, R0903, R0914, C0209, C0123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Change checkbox and radio button styles | ||
|
||
Similar to text fields discussed in the last chapter, PyPDFForm gives you the ability to | ||
modify some styles of checkboxes and radio buttons without changing the template. | ||
|
||
## Change size | ||
|
||
You can change the size of the selection by specifying a `float` value. Consider | ||
[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template.pdf): | ||
|
||
```python | ||
from PyPDFForm import PdfWrapper | ||
|
||
form = PdfWrapper("sample_template.pdf") | ||
form.widgets["check"].size = 50 | ||
form.widgets["check_2"].size = 40 | ||
form.widgets["check_3"].size = 60 | ||
|
||
form.fill( | ||
{ | ||
"check": True, | ||
"check_2": True, | ||
"check_3": True, | ||
}, | ||
) | ||
|
||
with open("output.pdf", "wb+") as output: | ||
output.write(form.read()) | ||
``` | ||
|
||
## Change button style | ||
|
||
The button style is the shape of the selection on a checkbox or radio button. PyPDFForm lets you pick | ||
three different button styles: `check`, `circle`, and `cross`. Consider | ||
[this PDF](https://github.com/chinapandaman/PyPDFForm/raw/master/pdf_samples/sample_template_with_radio_button.pdf): | ||
|
||
```python | ||
from PyPDFForm import PdfWrapper | ||
|
||
form = PdfWrapper("sample_template_with_radio_button.pdf") | ||
form.widgets["radio_1"].button_style = "cross" | ||
form.widgets["radio_2"].button_style = "circle" | ||
form.widgets["radio_3"].button_style = "check" | ||
|
||
form.fill( | ||
{ | ||
"radio_1": 0, | ||
"radio_2": 1, | ||
"radio_3": 2, | ||
}, | ||
) | ||
|
||
with open("output.pdf", "wb+") as output: | ||
output.write(form.read()) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ nav: | |
- inspect.md | ||
- fill.md | ||
- style.md | ||
- button_style.md | ||
- draw.md | ||
- utils.md | ||
theme: | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters