Preview PDF in the browser

Hi all,

I am trying to get a runtime binary string loaded to new tab as pdf. I am able to have it downloaded,but is there a way to have it previewed before downloading?

I have an equivalent in php which does this: \PDF::loadView(template,[data]) returns as object which gives me a pdf stream property.

1 Like

You’ll need to set headers so the browser knows it’s a pdf and to show it inline… eg:

show in browser:

Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"


Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"


alternatively for full control, you can use pdf.js - maybe combine/inline with a liveview etc