I have a Streamlit App where a PDF is rendered. The function to display the PDF on a specific page looks like this:
def displayPDF(file, page):
# Opening file from file path
with open(file, "rb") as f:
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
# Embedding PDF in HTML
pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}#page={page}" width="100%" height="300" type="application/pdf"></iframe>'
# Displaying File
st.markdown(pdf_display, unsafe_allow_html=True)
Now I want to also highlight or mark some text in the rendered PDF. How can I do this?
I already tried changing the iframe Code to this: pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}#page={page}&#search=%22Einleitung%22" width="100%" height="300" type="application/pdf"></iframe>'
So I added â&#search=â but this did not work. I donât want to only highlight one word, I would like to highlight a whole chunk on the specific doc.