Need some helps

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vuthcam
Forum Newbie
Posts: 2
Joined: Sat Sep 01, 2007 1:22 am

Need some helps

Post 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]
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

just checking, have you included the necessary library files for PDFlib?
vuthcam
Forum Newbie
Posts: 2
Joined: Sat Sep 01, 2007 1:22 am

Just the first time

Post 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
Post Reply