phpretard Posted March 21, 2008 Share Posted March 21, 2008 I am trying to dispaly a pdf doc and I keep getting the good ol' "Can't modify header..." I think I understand the problem in that any header modification should be done before the html output. When I take away Header( "Content-type: application/pdf"); all I get is, %PDF-1.5 %âãÏÓ 17 0 obj <> endobj xref 17 297 0000000016 00000 n 0000007055 00000 n 0000007164 00000 n 0000007637 00000 n 0000007670 00000 n 0000007997 00000 n 0000008559 00000 n 0000008818 00000 n 0000009104 ---- AND MUCH MORE Is there a meta tag that will cover any pdf display on every page? Is there a better way to display a PDF stored in my DB? $query = ("SELECT type,content FROM diagram where CNumber=$CNumber"); $result = MYSQL_QUERY($query); $data = MYSQL_RESULT($result,0,"content"); $type = MYSQL_RESULT($result,0,"type"); Header( "Content-type: application/pdf"); print $data; PLEASE LET ME KNOW IF THE QUETION ISN'T CLEAR...When I don't thoroughly understand the problem it is difficult to ask the question. Quote Link to comment Share on other sites More sharing options...
veridicus Posted March 21, 2008 Share Posted March 21, 2008 You could turn on output buffering, but the way you're doing it now should be sufficient. Are you outputting anything, even just a space or carriage return, before the header call? Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 21, 2008 Author Share Posted March 21, 2008 Definately ouptputting lots of thing before this, buit there is so much I would know where to begin correcting... What is output buffering and could it help? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 21, 2008 Share Posted March 21, 2008 if you're outputting ANYTHING before the PDF, it won't work. period. p.s., I suggest not storing binary files in a database. store the name of the file instead and send the file as needed. Quote Link to comment Share on other sites More sharing options...
marun Posted March 22, 2008 Share Posted March 22, 2008 Think about header() as special kind of echo(). Difference is header must be before any output other echo, printf,etc. Pdf files can't be inlined into html files. If you need access from page to pdf files create link in in html page wich will be pointing to your pdf file (script wich will generate pdf). If you must have pdf and html on one site you can try frames/iframes but how it will behave is browser+pdfreader dependant. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.