Re: PDF pain
| From: | Michael Hall | Date: | Sat, 20 Jul 2002 11:37:07 +0000 |
| Subject: | Re: PDF pain | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108649@lists.php.net to get a copy of this message | ||
Thanks for your pointers Richard, you've given me plenty of ideas for when
things go wrong as I continue to explore PHP and PDF.
As it turns out, my problem was a typo copied faithfully from 'Programming
PHP'. For anyone else trying the example (Hello world in PDF, on p 234),
make sure you use "application/x-pdf" in the Content-Type header, not
"application/pdf" as printed in the book.
If this really is a typo, could someone let me know and maybe I'll
register it with O'Reilly if they don't already know about it.
Typos happen in all books, especially technical books. Apart from this
small error (?), the book is great and has really filled out the holes in
my PHP knowledge.
Michael
On Sat, 20 Jul 2002, Richard Lynch wrote:
> >
> >Thanks for all the suggestions. I am making progress after discovering a
> >typo in my code (single quotes in a header() string containing a $var ...
> >double quotes fixed it).
> >
> >Now I get a pdf document but no text :-(
> >
> >If I save the doc to disk and try to open it with xpdf, it complains that
> >the "xref table" is broken and that it can't find a "trailer
> >dictionary".
>
> Even though you fixed one bug, make sure the header calls are at the end of
> your PHP script...
>
> Any other bugs lurking will show up in the browser before the Content-type,
> and you'll actually see them.
>
> I'd also make sure all my PDF/PHP code as doing as much error-checking as
> possible.
>
> Check all return values to be sure they are valid.
>
> I don't know what an xref table or trailer dictionary are, but if those are
> standard PDF elements, and your PHP code is trying to create them, I'd sure
> zero in on that section of code first, as well as the section immediately
> preceding it, which might be polluting the PDF stream of data with a PHP
> error message.
>
> Open up that PDF file in a text editor, and search for "Error" in it.
>
>