Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,14 +16,10 @@ def replace_red_text_with_data(doc_path, data_dict):
|
|
| 16 |
return doc
|
| 17 |
|
| 18 |
def process_files(pdf_file, template_docx):
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
doc_path = "temp_template.docx"
|
| 22 |
output_path = "filled_output.docx"
|
| 23 |
|
| 24 |
-
pdf_file.save(pdf_path)
|
| 25 |
-
template_docx.save(doc_path)
|
| 26 |
-
|
| 27 |
# Extract and parse PDF
|
| 28 |
raw_text = extract_text_from_pdf(pdf_path)
|
| 29 |
data_dict = parse_pdf_to_dict(raw_text)
|
|
@@ -33,10 +29,7 @@ def process_files(pdf_file, template_docx):
|
|
| 33 |
|
| 34 |
# Save final document
|
| 35 |
final_doc.save(output_path)
|
| 36 |
-
|
| 37 |
-
# Properly indented return
|
| 38 |
-
with open(output_path, "rb") as f:
|
| 39 |
-
return f
|
| 40 |
|
| 41 |
demo = gr.Interface(
|
| 42 |
fn=process_files,
|
|
|
|
| 16 |
return doc
|
| 17 |
|
| 18 |
def process_files(pdf_file, template_docx):
|
| 19 |
+
pdf_path = pdf_file
|
| 20 |
+
doc_path = template_docx
|
|
|
|
| 21 |
output_path = "filled_output.docx"
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
# Extract and parse PDF
|
| 24 |
raw_text = extract_text_from_pdf(pdf_path)
|
| 25 |
data_dict = parse_pdf_to_dict(raw_text)
|
|
|
|
| 29 |
|
| 30 |
# Save final document
|
| 31 |
final_doc.save(output_path)
|
| 32 |
+
return output_path
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
demo = gr.Interface(
|
| 35 |
fn=process_files,
|