vuthcam Posted September 1, 2007 Share Posted September 1, 2007 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. <?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. Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/ Share on other sites More sharing options...
Diamons Posted September 1, 2007 Share Posted September 1, 2007 I'm going to take a guess and say hello.php isn't in the same directory? Erm, just a question, though I doubt you'd make that mistake >_> Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-339181 Share on other sites More sharing options...
vuthcam Posted September 1, 2007 Author Share Posted September 1, 2007 This code is just to create hello.pdf. I think hello.php doesn't make any sense. This code is to create only the blank pdf as i wanna test for the first time. From : http://www.php.net/pdf Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-339186 Share on other sites More sharing options...
Timma Posted September 1, 2007 Share Posted September 1, 2007 Did you test the code before you modified it? And are you sure you have the PDFLib or whatever installed and enabled? Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-339243 Share on other sites More sharing options...
pyrodude Posted September 1, 2007 Share Posted September 1, 2007 I personally find the FPDF class (http://www.fpdf.com/) to be much more user friendly then PDFLib. That's just me though. The class is about 40k, plus font files. Not sure the size of PDFLib, but it's certainly a lot easier to create a file using FPDF. Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-339279 Share on other sites More sharing options...
Barand Posted September 1, 2007 Share Posted September 1, 2007 Did you mean http://www.fpdf.org Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-339324 Share on other sites More sharing options...
pyrodude Posted September 4, 2007 Share Posted September 4, 2007 Yeah, that...Lol. That's what I get for not checking the links before I post them... Quote Link to comment https://forums.phpfreaks.com/topic/67544-problem-with-using-php-to-create-pdf-file/#findComment-341113 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.