The question isn’t very clear, but I assume you’re writing a web application, and you’re trying to serve up the PDF document to the client.
First, you need to set a header to let the client know that it should expect PDF data:
header('Content-type: application/pdf');
That will cause most browsers to render the PDF within the browser window. If you’d rather have the browser offer the PDF as a download, do this in addition to the above:
header('Content-Disposition: attachment; filename="filename.pdf"');
You may set any filename you like in place of filename.pdf
.
It’s important that you make these calls to header()
before any output is written.
As an aside, I guess that $d
is a debug flag, but I don’t think it’s a very good idea to do those string operations that you’re doing when it’s set. You’re likely to end up corrupting the PDF data.
Daniel Cassidy
2010-08-18 03:12:06