Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -281,6 +281,23 @@ def save_docx_as_pdf1(input_path, output_path='output.pdf'):
|
|
281 |
# save_docx_as_pdf(resume_path, 'uploaded_resume.pdf')
|
282 |
# display_doc_as_image('uploaded_resume.pdf')
|
283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
def display_doc_as_image2(pdf_path):
|
285 |
# try:
|
286 |
# images = convert_from_path(pdf_path, size=800)
|
@@ -496,7 +513,7 @@ if uploaded_resume and uploaded_job_description:
|
|
496 |
display_doc_as_image2('/tmp/uploaded_resume.pdf')
|
497 |
with col2:
|
498 |
st.markdown("### Tailored Resume:")
|
499 |
-
|
500 |
# from io import BytesIO
|
501 |
# doc = Document()
|
502 |
|
|
|
281 |
# save_docx_as_pdf(resume_path, 'uploaded_resume.pdf')
|
282 |
# display_doc_as_image('uploaded_resume.pdf')
|
283 |
|
284 |
+
def display_pdf_page(pdf_path, page_number=1):
|
285 |
+
with open(pdf_path, 'rb') as file:
|
286 |
+
reader = PyPDF2.PdfReader(file)
|
287 |
+
page = reader.pages[page_number]
|
288 |
+
x_object = page.extract_text()
|
289 |
+
|
290 |
+
# Convert text to image (using PIL)
|
291 |
+
img = Image.new('RGB', (800, 1000))
|
292 |
+
draw = ImageDraw.Draw(img)
|
293 |
+
font = ImageFont.truetype("arial.ttf", 20)
|
294 |
+
|
295 |
+
# Draw text on the image
|
296 |
+
draw.text((10, 10), x_object[:500], fill=(255, 255, 255), font=font)
|
297 |
+
|
298 |
+
# Display the image
|
299 |
+
display(img)
|
300 |
+
|
301 |
def display_doc_as_image2(pdf_path):
|
302 |
# try:
|
303 |
# images = convert_from_path(pdf_path, size=800)
|
|
|
513 |
display_doc_as_image2('/tmp/uploaded_resume.pdf')
|
514 |
with col2:
|
515 |
st.markdown("### Tailored Resume:")
|
516 |
+
display_pdf_page(gen_pdf_path)
|
517 |
# from io import BytesIO
|
518 |
# doc = Document()
|
519 |
|