Testing PHP_PDF.DLL on IIS6 and Win2K3

2009-07-02 08:40 by Ian

This is a component that I tested for installation on CrystalTech’s PHP4 servers (yes, we still offer PHP4). Each time a customer requests a component, we have to test it to ensure that it won’t kill the resources on the server. This is the report that I gave to the other server admins…


Output directory:

Here is the code for the script:

ini_set('include_path', 'C:/php4/pdf-related');
	$counter = 0;
	// Uncomment the while loop to examine the script as it runs.
	//while($counter < 100){
		$pdf = pdf_new();
		$time_0 = time();		// Setup for time measurement.
		pdf_open_file($pdf, 'output'.$counter.'.pdf');
		$row = 10;
		$text = explode("%%%",file_get_contents('kjv10delim.txt'));
		pdf_begin_page($pdf, 400, 792); // Letter size
		pdf_set_parameter($pdf, 'FontOutline','Arial=C:/php4/arial.ttf');
		$font = pdf_findfont($pdf, "Arial", "host", 1);
		pdf_setfont($pdf, $font, 6);
		// Loops through each line in the input text and writes it
		// to the PDF. Checks for vertical page boundry and when encountered,
		// creates a new page.
		foreach($text as $t){
			pdf_show_xy($pdf, $t, 50, $row);
			$row = $row + 10;
			if($row >= 780){
				pdf_begin_page($pdf, 400, 792);
				pdf_set_parameter($pdf, 'FontOutline','Arial=C:/php4/arial.ttf');
				pdf_setfont($pdf, $font, 6);
				$row = 10;
		$time_1 = time();
		echo $counter.": Click <a href=\"output".$counter.".pdf\">here</a> for PDF. Total runtime was ".($time_1-$time_0)." seconds.<br>";

Test input data is about 4.3MB worth of text, and the product of the code is a 2.65MB PDF.
Please refer to the attached image for the following discussion.

Contrary to my prior hypothesis, the CPU use drops while the IO code runs. The peaks in the IO graph coincide with the troughs in the CPU graph. Memory use is basically flat while CPU pegs near a maximum of 25% for the bulk of the script’s execution time.

Really, the worst that this component will do is encourage people to use PHP. It doesn’t represent any resource use that, say, a flat-file database wouldn’t.

I vote to go ahead and install it. The only tricky thing will be the fonts, but I can handle that during installation.

We’re going to have customers wanting this or that font. TST will need to know that the customers can upload their own fonts and the PHP executable can use them right from their inetpub directory, just like the GD library can.