artificialguybr commited on
Commit
478120c
1 Parent(s): cf73656

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -29,21 +29,23 @@ def pdf_to_word(pdf_file):
29
  return docx_filename
30
 
31
  def word_to_pdf(docx_file):
32
- pdf_filename = docx_file.name.replace('.docx', '.pdf')
33
 
34
- doc = Document(docx_file.name)
35
  pdf = FPDF()
36
-
37
  pdf.add_page()
38
- pdf.set_font("Arial", size=12)
39
-
40
  for para in doc.paragraphs:
41
- pdf.multi_cell(0, 10, para.text)
42
-
 
 
 
43
  pdf.output(pdf_filename)
44
-
45
  return pdf_filename
46
 
 
47
  with gr.Blocks() as app:
48
  gr.Markdown(title_and_description)
49
 
 
29
  return docx_filename
30
 
31
  def word_to_pdf(docx_file):
32
+ pdf_filename = "output.pdf"
33
 
34
+ doc = Document(docx_file)
35
  pdf = FPDF()
 
36
  pdf.add_page()
37
+ pdf.set_font("Helvetica", size=12)
38
+
39
  for para in doc.paragraphs:
40
+ # Split the paragraph into lines
41
+ lines = para.text.split('\n')
42
+ for line in lines:
43
+ pdf.multi_cell(0, 10, line)
44
+
45
  pdf.output(pdf_filename)
 
46
  return pdf_filename
47
 
48
+
49
  with gr.Blocks() as app:
50
  gr.Markdown(title_and_description)
51