I've been trying to learn from http://hudzilla.org/phpwiki/index.php?title=Creating_a_PDF_with_PHP, but the following code gives me a 'document contains no data' message:
<?php
$pdf = pdf_new();
pdf_open_file($pdf, "/path/to/your.pdf");
$font = pdf_findfont($pdf, "Times-Roman", "host");
pdf_begin_page($pdf, 595, 842);
pdf_setfont($pdf, $font, 30);
pdf_show_xy($pdf, "Printing text is easy", 50, 750);
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
?>
I've got this far:
<?php
$filename = 'pdf\\testpdf.pdf';
$pdf = pdf_new();
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_open_file($pdf, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
$font = pdf_load_font($pdf, "Helvetica", "host", 0);
PDF_begin_page($pdf, 595, 842); /* start a new page */
?>
This gives me the message:
Fatal error: Uncaught exception 'PDFlibException' with message 'Unknown option '0'' in K:\xampp\htdocs\hudzilla\multimedia\mypdf.php:9 Stack trace: #0 K:\xampp\htdocs\hudzilla\multimedia\mypdf.php(9): pdf_load_font() #1 {main} thrown in K:\xampp\htdocs\hudzilla\multimedia\mypdf.php on line 9
I see that this is a problem with finding the font, so I looked up the following:
The files 'Helvetica.afm' appears in my K:\xampp\php\extras\pdf-related. The same file as well as Helvetica.pro appear in K:\xampp\htdocs\special\ps.
The file 'Helvetica.php' appears in both K:\xampp\php\PEAR\fpdf\font and K:\xampp\php\PEAR\File\PDF\fonts.
The only PDF-related extension which is enabled in php.ini is in this line:
extension=php_pdf.dll
I am using Xampp 1.6.7, which includes apache, php, mysql, etc.
Hopefully yours
Thanks in advance
C.