Problem with PHP - PDF generator

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1484
Joined: Fri Aug 29, 2003 8:39 pm

Problem with PHP - PDF generator

Post by ^rooker »

[PROBLEM]
When using "pdft.php" for generating a PDF sent to directly to the client's browser, I got the following errormessage:
Some data has already been output, can't send PDF file
[SOLUTION]
In order to see that the database connection was working properly, I output the connection identifier string (e.g. "echo $conn;").

BUT: Nothing (absolutely NOTHING) must be output when generating the PDF See: http://www.id.unizh.ch/cl/zinfo/fpdf/tutorial/tuto1.htm
Where the last paragraph says:
Caution: in case when the PDF is sent to the browser, nothing else must be output, not before nor after (the least space or carriage return matters). If you send some data before, you will get the error message: "Some data has already been output to browser, can't send PDF file". If you send after, your browser may display a blank page.
So I removed this single "echo" line and things finally worked!
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply