Skip to content

Commit

Permalink
Fixed / in data_dict for checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-houssian committed Nov 19, 2021
1 parent 3fb034e commit 0403cb8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
46 changes: 28 additions & 18 deletions WestHealth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -693,6 +693,9 @@
" try:\n",
" if type(annotation[ANNOT_VAL_KEY]) == pdfrw.objects.pdfstring.PdfString:\n",
" data_dict[key] = pdfrw.objects.PdfString.decode(annotation[ANNOT_VAL_KEY])\n",
" elif type(annotation[ANNOT_VAL_KEY]) == pdfrw.objects.pdfname.BasePdfName:\n",
" if '/' in annotation[ANNOT_VAL_KEY]:\n",
" data_dict[key] = annotation[ANNOT_VAL_KEY][1:]\n",
" except:\n",
" pass\n",
" elif annotation['/AP']:\n",
Expand Down Expand Up @@ -908,7 +911,14 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -917,7 +927,7 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": 66,
"metadata": {},
"outputs": [
{
Expand All @@ -928,17 +938,17 @@
" 'Dropdown1': '6',\n",
" 'Dropdown3': '2025',\n",
" 'Address': 'iejijiejfi',\n",
" 'Check Box1': '/Yes',\n",
" 'Check Box2': '/',\n",
" 'Check Box3': '/',\n",
" 'Check Box4': '/',\n",
" 'Check Box1': 'Yes',\n",
" 'Check Box2': '',\n",
" 'Check Box3': '',\n",
" 'Check Box4': '',\n",
" 'Text5': 'Yo',\n",
" 'Group6': '3',\n",
" 'Text6': 'Man',\n",
" 'Button7': None}"
]
},
"execution_count": 65,
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -951,7 +961,7 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -978,10 +988,10 @@
" 'Dropdown1': '6',\n",
" 'Dropdown3': '2025',\n",
" 'Address': 'iejijiejfi',\n",
" 'Check Box1': '/Yes',\n",
" 'Check Box2': '/',\n",
" 'Check Box3': '/',\n",
" 'Check Box4': '/',\n",
" 'Check Box1': '',\n",
" 'Check Box2': 'Yes',\n",
" 'Check Box3': '',\n",
" 'Check Box4': '',\n",
" 'Text5': 'Yo',\n",
" 'Group6': '3',\n",
" 'Text6': 'Man',\n",
Expand All @@ -999,7 +1009,7 @@
},
{
"cell_type": "code",
"execution_count": 67,
"execution_count": 78,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1008,7 +1018,7 @@
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 79,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1017,7 +1027,7 @@
},
{
"cell_type": "code",
"execution_count": 69,
"execution_count": 80,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1026,11 +1036,11 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 81,
"metadata": {},
"outputs": [],
"source": [
"write_fillable_pdf('new_samp.pdf', 'samp2.pdf', data_dict)"
"fillpdfs.write_fillable_pdf('new_samp.pdf', 'samp2.pdf', data_dict)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion fillpdf.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: fillpdf
Version: 0.4.1
Version: 0.4.2
Summary: A Library to fill and flatten pdfs
Home-page: https://github.com/t-houssian/fillpdf
Author: Tyler Houssian
Expand Down
Binary file modified fillpdf/__pycache__/fillpdfs.cpython-38.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions fillpdf/fillpdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def get_form_fields(input_pdf_path):
try:
if type(annotation[ANNOT_VAL_KEY]) == pdfrw.objects.pdfstring.PdfString:
data_dict[key] = pdfrw.objects.PdfString.decode(annotation[ANNOT_VAL_KEY])
elif type(annotation[ANNOT_VAL_KEY]) == pdfrw.objects.pdfname.BasePdfName:
if '/' in annotation[ANNOT_VAL_KEY]:
data_dict[key] = annotation[ANNOT_VAL_KEY][1:]
except:
pass
elif annotation['/AP']:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
t-houssian:
name = fillpdf
version = 0.4.1
version = 0.4.2
author = Tyler Houssian
author_email = [email protected]
description = A Library to fill and flatten pdfs
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
setup(
name='fillpdf',
packages=find_packages(exclude=['tests']),
version='0.4.1',
version='0.4.2',
install_requires=install_requires,
description='A Library to fill and flatten pdfs',
long_description=long_description,
Expand Down

0 comments on commit 0403cb8

Please sign in to comment.