PDA

View Full Version : how to create a pdf?


chris davies
05-22-2005, 11:01 AM
hello peeps tis me again,
I've been looking some scripts on creating a PDF. Part of the code I am using is as follows:

<?php
$pdf=pdf_new();
pdf_open_file($pdf,"C: \test.pdf");
pdf_set_info($pdf,"Author","Chris Davies");
pdf_set_info($pdf,"Title","Test PDF");
pdf_set_info($pdf,"Creator","Chris Davies");
pdf_set_info($pdf,"Subject","How to create a PDF in PHP");
pdf_begin_page($pdf,595,842);
$arial=pdf_findfont($pdf,"Arial","host",1);
pdf_setfont($pdf,$arial,14);
pdf_show_xy($pdf,"<Type your info here>",50,400);
$gif_image=pdf_open_gif($pdf,"images\cd-com.gif");
pdf_place_image($pdf,$gif_image,200,300,1.0);
pdf_close_image($pdf,$gif_image);
pdf_end_page($pdf);
pdf_close($pdf);
echo"<a href=\"C: \test.pdf\" target=\"_blank\"> open pdf in a new window</a>"
?>

However, I am getting an error message in my browser as follows:

Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope in c: \program files\apache group\apache\htdocs\createpdf.php on line 27

I am using this on my home system of WinXP Pro, Apache and PHP and I HAVE uncommented the PDF entries on my PHP.ini file, so as far I know, I am leaning in the right direction.
Can anyone shed some light of this erro please? As always, all replies accepted warmly.
Chris

chris davies
05-23-2005, 06:25 AM
I have now decided to run with FPDF, not only because it is free, but also as I am have some of my desired results.
http://fpdf.org/