Thus since it’s not served locally, and it’s not hosted externally, I’m not sure what would occupy the src property of either the iFrame or Embed components.
UPDATE:
Trying something along these lines:
encoded_image = base64.b64encode(open(asset_report_pdf, "rb").read())
PDF = html.Img(src=encoded_image.decode())
However this may not look good and you won’t get PDF features like text selection and copying. The only way I know to display a real PDF on a web-page without relying on external technologies like Adobe Acrobat is to use pdf.js.
It should be possible to take a React version of pdf.js and create a Dash component out of it:
dash.exceptions.InvalidCallbackReturnValue:
The callback for property `children` of component `transaction-table` returned a value which is not JSON serializable.
In general, Dash properties can only be dash components, strings, dictionaries, numbers, None, or lists of those.
If you have a PDF’s bytes, e.g. because you downloaded it with requests or you generated it and saved it to Python’s BytesIO, you can simply convert it to base64 and reutn the encoding and the base64 content to an iframe. For example:
r = requests.get(url)
encoded_string = base64.b64encode(r.content).decode('ascii')
html.Iframe(id="embedded-pdf", src=f"data:application/pdf;base64,{encoded_string}", width="100%", height="650px")
I only tested on Chrome, but googling indicates this works on many contemporary desktop browsers.