I'm having trouble outputting a pdf to the web. The layout is a select on the left, that has different pdf file names, and when the user chooses one, it is displayed on the right, through an ajax call. My pdfs are in a network folder where I can't use an URL, so what I do is reading it through php
$file = 'C:/Cargos/data.pdf' // trying it out first with filesystem
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=doc.pdf")
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
readfile($file);
The problem is that the output of this is somewhat garbage, this is the binary raw data of the pdf and I haven't found a way to load it, this is the response from ajax call:
/Creator (Canon iR-ADV C5235 PDF) /CreationDate (D:20150928152404+02'00') /Producer (\376\377\000A\000d\000o\000b\000e\000 \000P\000S\000L\000 \0001\000.\000\ 2\000e\000 \000f\000o\000r\000 \000C\000a\000n\000o\000n\000\000) x� \TU�8~���Lдt2C��W)njH�8�I�2���)���}͌�l�Q�
It goes on and on, I just cut it here.
I have made it work if I move the pdf to one temp folder with a fixed name and reload an iframe always pointing to that URL, but I feel that this is a really bad solution.
Any help on reading this binary input and displaying it? Thanks.