Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,14 @@ import os
|
|
| 3 |
from docx import Document
|
| 4 |
from utils import extract_text_from_pdf, parse_pdf_to_dict
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def replace_red_text_with_data(doc_path, data_dict):
|
| 7 |
doc = Document(doc_path)
|
| 8 |
|
| 9 |
for para in doc.paragraphs:
|
| 10 |
for run in para.runs:
|
| 11 |
-
if run.font.color and run.font.color.rgb and run.font.color.rgb
|
| 12 |
text = run.text.strip()
|
| 13 |
if text in data_dict:
|
| 14 |
run.text = data_dict[text]
|
|
|
|
| 3 |
from docx import Document
|
| 4 |
from utils import extract_text_from_pdf, parse_pdf_to_dict
|
| 5 |
|
| 6 |
+
from docx.shared import RGBColor
|
| 7 |
+
|
| 8 |
def replace_red_text_with_data(doc_path, data_dict):
|
| 9 |
doc = Document(doc_path)
|
| 10 |
|
| 11 |
for para in doc.paragraphs:
|
| 12 |
for run in para.runs:
|
| 13 |
+
if run.font.color and run.font.color.rgb and run.font.color.rgb == RGBColor(255, 0, 0):
|
| 14 |
text = run.text.strip()
|
| 15 |
if text in data_dict:
|
| 16 |
run.text = data_dict[text]
|