enricorampazzo commited on
Commit
8d06b39
·
1 Parent(s): 8dff1e3

first commit

Browse files
Files changed (4) hide show
  1. .gitignore +4 -0
  2. app.py +10 -0
  3. requirements.txt +2 -0
  4. schema.py +36 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .idea
2
+ form.pdf
3
+ /.idea/
4
+ /.idea/inspectionProfiles/
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from PyPDFForm.middleware.checkbox import Checkbox
2
+
3
+ if __name__ == '__main__':
4
+ import json
5
+
6
+ from PyPDF2 import PdfReader
7
+
8
+ form = PdfReader("form.pdf")
9
+ checkboxes = [v.name for k,v in form.get_fields().items() if v.field_type == "/Btn" and v.value == "/Yes"]
10
+ print(checkboxes)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ PyPDFForm
2
+ PyPDF2
schema.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TypedDict
2
+
3
+
4
+ class FormFields(TypedDict):
5
+ start_date: str
6
+ end_date: str
7
+ signed_by: str
8
+ signature_date: str
9
+ community: str
10
+ email: str
11
+ unit_no: str
12
+ contact_number: str
13
+ building_name: str
14
+ contractor_name: str
15
+ contractor_email: str
16
+ contractor_contact_number: str
17
+ occupant_name: str
18
+ civil: str
19
+ electrical_AC:str
20
+
21
+
22
+ form_fields_map: FormFields = {"start_date": "From", "end_date": "to", "signed_by": "name-10",
23
+ "signature_date": "From--1", "community": "Name-2", "email": "Name-3",
24
+ "unit_no": "Name-4", "contact_number": "Name-5", "building_name": "Name-6",
25
+ "contractor_name": "Name-7", "contractor_email": "name-8",
26
+ "contractor_contact_number": "name-9", "occupant_name":"name-1", "other_work": "name-19",
27
+ "civil":"3", "electrical_AC":"10", "furniture_delivery":"14", "handyman":"18",
28
+ "pest_control": "21", "sail_shade":"12", "wardrobes":"16", "wooden_flooring":"24",
29
+ "plumbing_sanitary":"4","safety systems":"4", "soft_landscaping":"9",
30
+ "balcony_tiles":"13", "bathroom_toilet_refurbish":"20",
31
+ "staircase_railing":"17", "storage_box":"11", "tiling_works":"15",
32
+ "doors_door_frames":"6", "gypsum_ceiling":"22", "kitchen_refurbish":"7",
33
+ "lights_and_sockets":"23", "painting_wallpapering":"19",
34
+ "seating_area_barbecuing_fountain":"8",
35
+ "other_work_checkbox": "69", "owner":"Check Box4", "tenant":"Check Box3"}
36
+