PDF in PHP4?

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
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

PDF in PHP4?

Post by Jr »

I was just curious if it is possible to make PDF files in PHP4? I tested out a little tutorial in my PHP5 book and it doesn't seem to work. I'm not sure if I just missed something or is that just a new feature to PHP5?

Code: Select all

<?php
	
	define('PAGE_WIDTH', 612);
	define('PAGE_HEIGHT', 792);
	
	$pdf = pdf_new();
	pdf_begin_document($pdf, "", "");
	pdf_begin_page($pdf, PAGE_WIDTH, PAGE_HEIGHT);
	
	// SHOW STUFF HERE
	
	pdf_end_page($pdf);
	pdf_end_document($pdf, "");
	
	$data = pdf_get_buffer($pdf);
	header('Content-type: application/pdf');
	header("Content-disposition: inline; filename=example1.pdf");
	header("Content-length: " . strlen($data));
	
	echo "$data";
?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You need to install the pdf extension..

http://www.php.net/pfd From there you can find all the required info.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

might help to spell it right ;) http://www.php.net/pdf
Post Reply