Page 1 of 1

Need some helps

Posted: Sat Sep 01, 2007 1:27 am
by vuthcam
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have some problems with using php to create PDF file. I have tested my php and making PDF already enabled. But when testing the code below, it always takes me to Page not found.

Code: Select all

<?php

try {
    $p = new PDFlib();

    $p->begin_document(NULL,NULL);
    $p->set_info("Creator", "hello.php");
    $p->set_info("Author", "Rainer Schaaf");
    $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: attachment; filename=hello.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;
?>
I wonder what the reason is??
Thanks in advance for your help.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Sep 01, 2007 5:11 am
by Kieran Huggins
just checking, have you included the necessary library files for PDFlib?

Just the first time

Posted: Sat Sep 01, 2007 12:56 pm
by vuthcam
It's the first time i wanna do that. So that i am not really sure about that. Searching through php.net, i found out that php_pdflib in PHP4 is divided into 2 files. I copied those files to c:\php\ext. When displaying phpinfo(), it works coz i see pdf extension there. Would you mind showing me the whole files of that librabry and its use??

Thanks in advance

vuthcam