I use FPDF to generate some PDF from a PHP. It worked great for small exemple but now i got a problem with it : it return some data which i saw in the console but no file !
ouput look likes – it’s the PDF no ?
%PDF-1.4
0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>
......
<<
/Size 15
/Root 14 0 R
/Info 13 0 R
>>
startxref
22291
%%EOF
And my php is pretty long, here is a pastebin of it http://pastebin.com/ri5uAeie
My php looks correct, really weird no ?
UPDATE
I pass my param throw the URL and with a $_GET and it works well 🙂 Thanks for your help guys !
You’ve probably added a blank line somewhere, possibly at
inc/DataLib.php.Update #1:
According to your answers, there’s two suspicious points:
The
Content-Typeshould beapplication/pdf. In theory, the PDF::Output() method adds it for you (unlessphp_sapi_name()returnscli, which should not be possible in web environment).Getting a blank page in a desktop PDF reader (rather than an error) suggests that the document is damaged in a way that the reader cannot even detect it… or that the document is actually blank.
No idea about #1 (firewall? proxy? antivirus?) but you could at least inspect the PDF source in search of PHP error messages or something that does not belong there.
Update #2:
I think I finally understood what your problem is. You cannot use JavaScript to retrieve a PDF file though AJAX. All JavaScript can do is:
I suspect your PDF generator is just fine if you call it directly from the location bar.