I know there isn’t a simple way to do this, but is there a reasonable workaround to insert local PDF in streamlit?
Here’s what I’ve tried:
-
Use
embed
in html in markdown:
Initially I was getting 404 error because I was using relative path insrc
but I managed to get past that by setting thesrc
to befile:///home/username/path_to_file
as opposed to/home/username/path_to_file
. Now I am getting error
Blocked http://xxx from loading file:///yyy Refused to load a local file in a non-local page for security reasons
. Stuck there -
JS in html markdown:
To avoid accessing local files via third party scripts from the browser I downloaded js library (PDFObject js) locally. However, now I can’t embed it into the html cause streamlit doesn’t seem to allowscript
tags in html in markdown. -
(not streamlit issue) pdf2image
Tried pdf2image to convert the pdf to image first and then render it usingst.image
but all I got is 1x1 blank image. This doesn’t seem to be streamlit issue cause I tried it from terminal using the underlying tools that pdf2image uses and still got the same result. The pdf is only one page but has quite complex content which might be an issue.
Is there any way I can insert local PDF into my streamlit app? It is central part of the app and the main reason why I needed a visualization app in the first place
Thank you in advance!