-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_usage.py
More file actions
179 lines (176 loc) · 4.48 KB
/
Copy pathexample_usage.py
File metadata and controls
179 lines (176 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
from dict2pdf import PDFGenerator, DEFAULT_STYLES
import pandas as pd
import numpy as np
custom_styles = {
'table_title': {
'font_size': 18,
'space_after': 20,
'text_transform': 'capitalize'
},
'cell': {
'word_wrap': False,
'leading': 17
}
}
# Example usage with different dictionary structures
data = [
{
"id": "P1001",
"title": "Urban Air Quality Study",
"status": "active",
"timeframe": {
"start": "2023-01-15",
"end": "2023-12-31"
},
"budget": "$120,000",
"lead_researcher": {
"name": "Dr. Sarah Chen",
"department": "Environmental Science"
}
},
{
"id": "P1002",
"title": "Renewable Energy Optimization",
"status": "planning",
"timeframe": {
"start": "2023-03-01",
"end": "2024-02-28"
},
"budget": "$85,000",
"lead_researcher": {
"name": "Prof. James Wilson",
"department": "Engineering"
}
},
{
"id": "P1003",
"title": "Coastal Erosion Analysis",
"status": "completed",
"timeframe": {
"start": "2022-06-01",
"end": "2023-01-30"
},
"budget": "$65,000",
"lead_researcher": {
"name": "Dr. Maria Garcia",
"department": "Geology"
}
},
{
"id": "P1004",
"title": "AI for Medical Diagnostics",
"status": "active",
"timeframe": {
"start": "2023-02-10",
"end": "2024-06-15"
},
"budget": "$210,000",
"lead_researcher": {
"name": "Dr. Alan Turing",
"department": "Computer Science"
}
},
{
"id": "P1005",
"title": "Nanomaterials for Solar Cells",
"status": "active",
"timeframe": {
"start": "2022-11-01",
"end": "2023-10-31"
},
"budget": "$175,000",
"lead_researcher": {
"name": "Dr. Lisa Zhang",
"department": "Materials Science"
}
},
{
"id": "P1006",
"title": "Behavioral Economics Study",
"status": "completed",
"timeframe": {
"start": "2021-09-01",
"end": "2022-08-31"
},
"budget": "$92,000",
"lead_researcher": {
"name": "Dr. Robert Kahn",
"department": "Economics"
}
},
{
"id": "P1007",
"title": "Antibiotic Resistance Research",
"status": "active",
"timeframe": {
"start": "2023-04-01",
"end": "2025-03-31"
},
"budget": "$340,000",
"lead_researcher": {
"name": "Dr. Emma Watson",
"department": "Microbiology"
}
},
{
"id": "P1008",
"title": "Smart City Infrastructure",
"status": "planning",
"timeframe": {
"start": "2024-01-01",
"end": "2026-12-31"
},
"budget": "$500,000",
"lead_researcher": {
"name": "Dr. Mark Lee",
"department": "Urban Planning"
}
},
{
"id": "P1009",
"title": "Quantum Computing Algorithms",
"status": "active",
"timeframe": {
"start": "2022-07-01",
"end": "2024-06-30"
},
"budget": "$275,000",
"lead_researcher": {
"name": "Dr. Priya Patel",
"department": "Physics"
}
},
{
"id": "P1010",
"title": "Marine Biodiversity Catalog",
"status": "completed",
"timeframe": {
"start": "2020-05-01",
"end": "2022-04-30"
},
"budget": "$150,000",
"lead_researcher": {
"name": "Dr. Carlos Mendez",
"department": "Marine Biology"
}
}
]
# Generate PDF (horizontal layout)
PDFGenerator.generate_pdf_from_dict(
data,
output_file="dataframe_horizontal.pdf",
title="Research Projects",
layout="horizontal",
output_dir="output_pdfs", # Specify output directory
title_key="title", # Use Name column as entry titles
styles=custom_styles
)
# Generate PDF (vertical layout)
PDFGenerator.generate_pdf_from_dict(
data,
output_file="dataframe_vertical.pdf",
title="Research Projects",
layout="vertical",
output_dir="output_pdfs", # Specify output directory
styles=custom_styles
)