Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,6 +71,12 @@ except: # Handle blank file error
|
|
| 71 |
st.error('Please select a valid file')
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
# Processs to trigger summary
|
|
@@ -78,7 +84,10 @@ if st.button('Summarize pdf content'):
|
|
| 78 |
with st.spinner('Extracting text from PDF...'):
|
| 79 |
pdf_input = extract_text(uploaded_pdf)
|
| 80 |
st.success('Text extracted')
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
with st.spinner('Summarizing extracted text...'):
|
| 83 |
pdf_output = []
|
| 84 |
|
|
@@ -103,11 +112,14 @@ if st.button('Summarize pdf content'):
|
|
| 103 |
# Summary text to PDF function
|
| 104 |
def summary_download():
|
| 105 |
# summary_pdf = pdfkit.from_string(pdf_summary, 'Summary.pdf')
|
| 106 |
-
st.download_button(label='Download summary PDF', data=pdf_summary, file_name='summary.pdf', mime='application/pdf')
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
if st.button('Generate pdf download link'):
|
| 109 |
summary_download()
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
st.write('')
|
| 113 |
st.write('')
|
|
|
|
| 71 |
st.error('Please select a valid file')
|
| 72 |
|
| 73 |
|
| 74 |
+
def check_page_count(pdf):
|
| 75 |
+
pdf_content = PdfReader(pdf)
|
| 76 |
+
pages =pdf_content.pages
|
| 77 |
+
page_count = len(pages)
|
| 78 |
+
|
| 79 |
+
return page_count
|
| 80 |
|
| 81 |
|
| 82 |
# Processs to trigger summary
|
|
|
|
| 84 |
with st.spinner('Extracting text from PDF...'):
|
| 85 |
pdf_input = extract_text(uploaded_pdf)
|
| 86 |
st.success('Text extracted')
|
| 87 |
+
|
| 88 |
+
num_of_pages = check_page_count(uploaded_pdf)
|
| 89 |
+
st.success(f'NUmber of pages is {num_of_pages}.')
|
| 90 |
+
|
| 91 |
with st.spinner('Summarizing extracted text...'):
|
| 92 |
pdf_output = []
|
| 93 |
|
|
|
|
| 112 |
# Summary text to PDF function
|
| 113 |
def summary_download():
|
| 114 |
# summary_pdf = pdfkit.from_string(pdf_summary, 'Summary.pdf')
|
| 115 |
+
download_button = st.download_button(label='Download summary PDF', data=pdf_summary, file_name='summary.pdf', mime='application/pdf')
|
| 116 |
+
return download_button
|
| 117 |
+
|
| 118 |
+
|
| 119 |
if st.button('Generate pdf download link'):
|
| 120 |
summary_download()
|
| 121 |
+
|
| 122 |
+
|
| 123 |
|
| 124 |
st.write('')
|
| 125 |
st.write('')
|