Hello everyone,
been growing grey hairs(more than my usual few) over the last couple of days trying to output a PDF page from my php code.The code is a simple one from an online example and getting it to run as been one big headache.It's as follows:
<?php
$user = $HTTP_POST_VARS["userName"];
$pdf = pdf_new();
pdf_open_file($pdf, "obiboy.pdf");
pdf_set_info($pdf, "Author", "J.F.Kennedy");
pdf_set_info($pdf, "Title", "Creating a pdf");
pdf_set_info($pdf, "Creator", "J.F.Kennedy");
pdf_set_info($pdf, "Subject", "Creating a pdf");
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, "baseball.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:\obiboy.pdf\" TARGET=\"_blank\">Open pdf in a new window $user</A>"
?>
Its meant to carry details from a sign in page as reflected by the declared globals on top.Even though I have enabled usage of PDF extension in my php.ini, the code dosent run.
The error it returns is as follows:
Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope in c:\inetpub\wwwroot\pdf_house\pdf_file.php on line 6
so can someone please look it over and tell me where I am screwing it up?
Thanks all.