-
October 30th, 2009, 02:21 AM
#1
Using PHP to create a PDF with PDFlib
I am attempting to create an Adobe Acrobat doc on the fly using the PHP5 library PDFlib. However, when I run the test.php script the browser times out and gives an HTTP 500 internal server error stating that the site is either under maintenance or has a programming error.
Any help would be appriciated.
Here is the test.php code, obtained from php.net (I've only changed; Creator name, Author name, and resulting PDF file name):
<?php
try {
$p = new PDFlib();
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "test.php");
$p->set_info("Author", "smokebox");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=test.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
-
October 30th, 2009, 11:01 AM
#2
Can I get the test URL on our servers so we can check this out for you?
-
October 30th, 2009, 12:26 PM
#3
-
October 30th, 2009, 03:49 PM
#4
When I run the test, I get an error. After researching, it appears to be a documented bug
-
November 2nd, 2009, 03:55 AM
#5
Thank you for the info, the page continually timed out for me prior to printing the error. It's unfortunate the bug ticket has been open >8 months with no update.
Per References 1 and 2 (listed below), it appears that PDFLib requires a commercial license for proper operation in a hosting environment. I do not see it explicitly stated on hostek.com that this license is available.
Does Hostek have a commercial PDFlib license (which matches the currently installed version)?
If so, can the examples distributed with the PDFlib product be successfully executed (Reference 1)?
If not, then I will check out fpdf (Reference 3). This seems to be an open source, pure PHP scripting solution for generating PDFs, independant of the PDFlib extension.
Reference 1: PDFlib.com
http://www.pdflib.com/fileadmin/pdfl...-PHP-HowTo.pdf
Reference 2: ThePlanet.com
http://forums.theplanet.com/lofivers...hp/t60008.html
Reference 3: fPDF.org
http://www.fpdf.org
Last edited by smokebox; November 2nd, 2009 at 03:59 AM.
-
November 2nd, 2009, 10:18 AM
#6
We do not have a commercial PDFlib license installed. The fPDF looks like that should work for you.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules