Results 1 to 6 of 6

Thread: Using PHP to create a PDF with PDFlib

  1. #1
    Join Date
    Oct 2009
    Posts
    6

    Question 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;
    ?>

  2. #2
    Join Date
    May 2009
    Location
    Tulsa, OK
    Posts
    220

    Default

    Can I get the test URL on our servers so we can check this out for you?

  3. #3
    Join Date
    Oct 2009
    Posts
    6

  4. #4
    Join Date
    May 2009
    Location
    Tulsa, OK
    Posts
    220

    Default

    When I run the test, I get an error. After researching, it appears to be a documented bug

  5. #5
    Join Date
    Oct 2009
    Posts
    6

    Default

    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.

  6. #6
    Join Date
    May 2009
    Location
    Tulsa, OK
    Posts
    220

    Default

    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
  •