pktpaulie commited on
Commit
34ad7db
·
verified ·
1 Parent(s): 371457f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -27
app.py CHANGED
@@ -327,27 +327,30 @@ def display_doc_as_image2(pdf_path):
327
  # display(Image(filename=images[0].filename))
328
  # except Exception as e:
329
  # st.error(f"Failed to display image: {str(e)}")
330
- try:
331
- # Convert PDF to images
332
- images = []
333
- for i in range(1): # Assuming only one page
334
- command = [
335
- "pdf2image", "-j", "--png",
336
- "-f", str(i+1),
337
- "-l", str(i+1),
338
- pdf_path
339
- ]
340
- output = subprocess.check_output(command)
 
 
 
341
 
342
- # Decode the base64 image data
343
- img_data = base64.b64decode(output.split()[0])
344
- img = Image.open(BytesIO(img_data))
345
- images.append(img)
346
 
347
- # Display the first page
348
- display(images[0])
349
- except Exception as e:
350
- st.error(f"Failed to display image: {str(e)}")
351
 
352
  def display_doc_as_image3(pdf_path):
353
  try:
@@ -367,12 +370,13 @@ def display_doc_as_image3(pdf_path):
367
  # except Exception as e:
368
  # st.error(f"Failed to display image: {str(e)}")
369
 
370
- def display_doc_as_image1(pdf_path):
371
- try:
372
- img = Image.open(pdf_path)
373
- st.image(img)
374
- except Exception as e:
375
- st.error(f"Failed to display image: {str(e)}")
 
376
 
377
 
378
  def display_doc_as_image(file_path):
@@ -533,10 +537,10 @@ if uploaded_resume and uploaded_job_description:
533
  with col1:
534
  st.markdown("### Uploaded Resume:")
535
  save_docx_as_pdf(resume_path, '/tmp/uploaded_resume.pdf')
536
- display_pdf_page1('/tmp/uploaded_resume.pdf')
537
  with col2:
538
  st.markdown("### Tailored Resume:")
539
- display_pdf_page(gen_pdf_path)
540
  # from io import BytesIO
541
  # doc = Document()
542
 
 
327
  # display(Image(filename=images[0].filename))
328
  # except Exception as e:
329
  # st.error(f"Failed to display image: {str(e)}")
330
+
331
+ <iframe src=pdf_path width="100%" height="600px"></iframe>
332
+
333
+ # try:
334
+ # # Convert PDF to images
335
+ # images = []
336
+ # for i in range(1): # Assuming only one page
337
+ # command = [
338
+ # "pdf2image", "-j", "--png",
339
+ # "-f", str(i+1),
340
+ # "-l", str(i+1),
341
+ # pdf_path
342
+ # ]
343
+ # output = subprocess.check_output(command)
344
 
345
+ # # Decode the base64 image data
346
+ # img_data = base64.b64decode(output.split()[0])
347
+ # img = Image.open(BytesIO(img_data))
348
+ # images.append(img)
349
 
350
+ # # Display the first page
351
+ # display(images[0])
352
+ # except Exception as e:
353
+ # st.error(f"Failed to display image: {str(e)}")
354
 
355
  def display_doc_as_image3(pdf_path):
356
  try:
 
370
  # except Exception as e:
371
  # st.error(f"Failed to display image: {str(e)}")
372
 
373
+ def display_doc_as_image1(pdf_url):
374
+ st.components.v1.iframe(pdf_url, width=800, height=600)
375
+ # try:
376
+ # img = Image.open(pdf_path)
377
+ # st.image(img)
378
+ # except Exception as e:
379
+ # st.error(f"Failed to display image: {str(e)}")
380
 
381
 
382
  def display_doc_as_image(file_path):
 
537
  with col1:
538
  st.markdown("### Uploaded Resume:")
539
  save_docx_as_pdf(resume_path, '/tmp/uploaded_resume.pdf')
540
+ display_doc_as_image1('/tmp/uploaded_resume.pdf')
541
  with col2:
542
  st.markdown("### Tailored Resume:")
543
+ display_doc_as_image2(gen_pdf_path)
544
  # from io import BytesIO
545
  # doc = Document()
546