Manikandan-Alagu commited on
Commit
b621482
·
verified ·
1 Parent(s): ec5fa1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -11,8 +11,7 @@ from langchain_openai import ChatOpenAI
11
  from langchain.prompts import PromptTemplate
12
  from langchain.chains import LLMChain
13
  from langchain.chains import SequentialChain
14
- import pdfkit
15
- import wkhtmltopdf
16
 
17
  with open('Response.json', 'r') as file:
18
  RESPONSE_JSON = json.load(file)
@@ -74,6 +73,7 @@ with st.form("user_inputs"):
74
  def download(df):
75
  col1, col2 = st.columns(2)
76
  html_content=df.to_html(index=False)
 
77
 
78
  if button:
79
  col1.download_button(label="Download CSV",
@@ -83,8 +83,10 @@ def download(df):
83
  help="Click to download as CSV"
84
  )
85
 
86
- config = pdfkit.configuration(wkhtmltopdf='wkhtmltopdf')
87
- col2.button(label="Download PDF", on_click=lambda: pdfkit.from_string(html_content, 'generated_mcqs.pdf', configuration=config), key="pdf-download")
 
 
88
 
89
 
90
 
 
11
  from langchain.prompts import PromptTemplate
12
  from langchain.chains import LLMChain
13
  from langchain.chains import SequentialChain
14
+ from weasyprint import HTML
 
15
 
16
  with open('Response.json', 'r') as file:
17
  RESPONSE_JSON = json.load(file)
 
73
  def download(df):
74
  col1, col2 = st.columns(2)
75
  html_content=df.to_html(index=False)
76
+ pdf_path= "generated_mcqs.pdf"
77
 
78
  if button:
79
  col1.download_button(label="Download CSV",
 
83
  help="Click to download as CSV"
84
  )
85
 
86
+ col2.download_button(label="Download PDF",
87
+ data= HTML(string=html_content).write_pdf(pdf_path),
88
+ key="pdf-download",
89
+ help="Click to download as PDF")
90
 
91
 
92