Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1359,6 +1359,21 @@ def create_pdf(cname,ename,account_number, directory):
|
|
| 1359 |
document_created = True
|
| 1360 |
with open(output_file_name, "wb+") as output:
|
| 1361 |
output.write(filled.read())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1362 |
# Get the absolute path
|
| 1363 |
file_path = os.path.abspath(output_file_name)
|
| 1364 |
print(f"The file was created at: {file_path}")
|
|
|
|
| 1359 |
document_created = True
|
| 1360 |
with open(output_file_name, "wb+") as output:
|
| 1361 |
output.write(filled.read())
|
| 1362 |
+
|
| 1363 |
+
from PyPDF2 import PdfReader, PdfWriter
|
| 1364 |
+
|
| 1365 |
+
reader = PdfReader(output_file_name)
|
| 1366 |
+
writer = PdfWriter()
|
| 1367 |
+
|
| 1368 |
+
for page in reader.pages:
|
| 1369 |
+
page.merge_page(page) # Flatten content
|
| 1370 |
+
writer.add_page(page)
|
| 1371 |
+
|
| 1372 |
+
with open(output_file_name, "wb") as output_file_name:
|
| 1373 |
+
writer.write(output_file_name)
|
| 1374 |
+
|
| 1375 |
+
|
| 1376 |
+
|
| 1377 |
# Get the absolute path
|
| 1378 |
file_path = os.path.abspath(output_file_name)
|
| 1379 |
print(f"The file was created at: {file_path}")
|