pktpaulie commited on
Commit
2d5b92f
·
verified ·
1 Parent(s): 1865a58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -3
app.py CHANGED
@@ -282,9 +282,30 @@ def save_docx_as_pdf1(input_path, output_path='output.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)
287
- display(Image(filename=images[0].filename))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  except Exception as e:
289
  st.error(f"Failed to display image: {str(e)}")
290
 
@@ -464,7 +485,7 @@ if uploaded_resume and uploaded_job_description:
464
  display_doc_as_image2('/tmp/uploaded_resume.pdf')
465
  with col2:
466
  st.markdown("### Tailored Resume:")
467
- display_doc_as_image5(gen_pdf_path)
468
  # from io import BytesIO
469
  # doc = Document()
470
 
 
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)
287
+ # display(Image(filename=images[0].filename))
288
+ # except Exception as e:
289
+ # st.error(f"Failed to display image: {str(e)}")
290
  try:
291
+ # Convert PDF to images
292
+ images = []
293
+ for i in range(1): # Assuming only one page
294
+ command = [
295
+ "pdf2image", "-j", "--png",
296
+ "-f", str(i+1),
297
+ "-l", str(i+1),
298
+ pdf_path
299
+ ]
300
+ output = subprocess.check_output(command)
301
+
302
+ # Decode the base64 image data
303
+ img_data = base64.b64decode(output.split()[0])
304
+ img = Image.open(BytesIO(img_data))
305
+ images.append(img)
306
+
307
+ # Display the first page
308
+ display(images[0])
309
  except Exception as e:
310
  st.error(f"Failed to display image: {str(e)}")
311
 
 
485
  display_doc_as_image2('/tmp/uploaded_resume.pdf')
486
  with col2:
487
  st.markdown("### Tailored Resume:")
488
+ display_doc_as_image3(gen_pdf_path)
489
  # from io import BytesIO
490
  # doc = Document()
491