import streamlit as st
import fitz
import base64
def display_scrollable_pages():
if st.session_state.get("uploaded_pdf_bytes") is not None:
pdf_document = None
try:
pdf_document = fitz.open(stream=st.session_state.get("uploaded_pdf_bytes"), filetype="pdf")
# CSS styles
css = """
"""
# Build HTML content
html_content = css + '
'
# Render with st.html()
st.html(html_content)
except Exception as e:
st.error(f"Failed to render PDF pages: {e}")
finally:
if pdf_document is not None:
pdf_document.close()
else:
st.warning("No PDF file uploaded. Please upload a PDF file to generate questions from a chapter.")
def select_chapter():
"""
Displays a radio button selection for chapters extracted from the TOC.
"""
if st.session_state.get('chapters_dict') is not None:
chapters = st.session_state['chapters_dict']
with st.container():
# Custom CSS for chapter selection
st.html("""