Page 1 of 1

Good PDF Tutorial?

Posted: Thu Nov 03, 2005 5:28 pm
by JasonTC
I've found a couple, but apparently I'm missing some key concept or something. I tried this incredibly simple script, for the most part copied and pasted from the php.net site:

Code: Select all

<?php
$pdf = pdf_new();
pdf_open_file($pdf, "test.pdf");
pdf_set_info($pdf, "Author", "Uwe Steinmann");
pdf_set_info($pdf, "Title", "Test for PHP wrapper of PDFlib 2.0");
pdf_set_info($pdf, "Creator", "See Author");
pdf_set_info($pdf, "Subject", "Testing");
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, "Page 1");
$font = pdf_findfont($pdf, "Times-Roman", "host", 0);
pdf_setfont($pdf, $font, 10);
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
pdf_end_page($pdf);
pdf_close($pdf);
//pdf_delete($pdf);
?>
It creates no file called "test.pdf". Creates no file at all. What could I have done wrong? I tried it with the pdf_delete both commented and uncommented; I thought that might make a difference, but it didn't. If someone could point me in the direction of a "PDF Tutorial for First Graders", that would be great. I haven't found anything that really seems to start from the very basic building blocks of a PDF file yet.

Thanks,
Jason

Posted: Thu Nov 03, 2005 5:31 pm
by John Cartwright
First of all, do you have the PDFlib library installed?

Posted: Thu Nov 03, 2005 5:34 pm
by JasonTC
Apparently. Here's my deal: I just got hired at a company whose former programmer left and cannot be contacted in any way. I'm left to decipher the spaghetti code he left behind. One script he wrote is supposed to generated PDF files, and it does...sometimes. So since it works sometimes, I'm guessing the PDFlib is installed.

Posted: Thu Nov 03, 2005 6:48 pm
by timvw
First thing to do:

Code: Select all

ini_set('display_errors', TRUE);
ini_set('error_reporting', E_ALL);
If the code is running on a production server you better log it to a file instead of displaying though ;)

Posted: Thu Nov 03, 2005 7:09 pm
by JasonTC
Thanks, but this yields no errors.

Posted: Thu Nov 03, 2005 7:34 pm
by timvw
I've tested on Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.8 PHP/5.0.5 Server at localhost Port 80

If i use a relative path in pdf_open, eg: "test.pdf" there is no file created...
If i use an absoltue path it does work, eg: pdf_open_file($pdf, "f:/websites/localhost/test.pdf");

Posted: Thu Nov 03, 2005 7:44 pm
by timvw
I just ran a search on my filesystem for test.pdf...
Apparently there was a test.pdf generated in c:/program files/apache group/apache2. I've got a feeling there is a little "bug/feature" in the win32 version of that extension :)