I am using output buffering to grab a pdf file from a network share via PHP using a proxy-handler and readfile(). I display this in a new browser tab by specifying the content/mime type. (http://stackoverflow.com/questions/10121903/php-scandir-explorer-view-to-display-network-share-files-file-via-wamp-wor)
I use jQuery / Ajax throughout the rest of the application. Is it possible to inject the raw PDF content into a div tag using ajax but get it to display correctly? Currently the required header (header("Content-type: application/pdf")) seems to be stripped by the ajax request and it is displaying jibberish.
Edit: Thankyou all for the comments and answers. I will respond in more detail and review my options shortly.
@ Murtaza - the question link above shows how I got to the raw PDF, in addition I have used $.ajax to send the request to the div tag and used an iframe which sort of worked when I rendered it into the code as src=, rather than Ajax.
@ Brad Christie / Quentin - Perhaps I could use an iFrame or Modal to display the content? I have tested pdfobject.js which is good but requires a linked file (e.g. /files/file.pdf). It sounds horrific but what if I use PHP to write a temporary file to the web root and then display? The only other thing I can think could be useful might be the jQuery PDF library if anyone has used it?
@ Ignacio - I did try this with the following code. It rendered the jibberish. I'm probably doing it wrong as I have no experience with iFrames. // Where $filename is the raw PDF data ">
James.