[PHP-DEV] php-3.0.12 broken with pdflib-2.01, patch supplied From: Simon Greaves (Simon.Greaves <email protected>)
Date: 08/17/99

The API of pdflib has changed in version 2.01. It looks like php-3.0.12
doesn't support this version officially yet, so in the interim here's a
quick & dirty hack to get it to compile. There's a fix for the
pdf_clock.php3 test too.

Also, do you make diffs between releases available? We have a 64k line
here shared by the whole University community (seriously!) so big
downloads are a real pain. I just diffed 3.0.11 and 3.0.12 and got a 65K
gzipped file, much easier to get (only take an hour or two ;-)

Thanks,

Simon

--
Simon Greaves				voice: (+679) 212114
Computer Centre				fax:   (+679) 304089
The University of the South Pacific	email: Simon.Greaves <email protected>
Suva, Fiji

8<-------------------------------------------------------- *** functions/pdf.c.orig Tue Aug 17 15:25:57 1999 --- functions/pdf.c Tue Aug 17 15:41:38 1999 *************** *** 2251,2258 **** } ! pdf_image = PDF_open_memory_image(pdf, buffer, im->sx, im->sy, 3, 8); ! if(0 > pdf_image) { php3_error(E_WARNING, "Could not open image"); RETURN_FALSE; --- 2251,2259 ---- } ! pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, count, ! im->sx, im->sy, 3, 8, NULL); ! if(0 > pdf_image) { php3_error(E_WARNING, "Could not open image"); RETURN_FALSE; *************** *** 2408,2415 **** RETURN_FALSE; } - PDF_put_image(pdf, pdf_image); - RETURN_TRUE; } /* }}} */ --- 2409,2414 ---- *************** *** 2456,2462 **** convert_to_double(arg4); convert_to_double(arg5);

! PDF_execute_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval, arg5- >value.dval); RETURN_TRUE; } --- 2455,2461 ---- convert_to_double(arg4); convert_to_double(arg5); ! PDF_place_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval, arg5->v alue.dval); RETURN_TRUE; } *** tests/pdf_clock.php3.orig Fri Jul 16 02:14:43 1999 --- tests/pdf_clock.php3 Wed Aug 18 11:55:33 1999 *************** *** 1,90 **** <?php // This only works with pdflib 2.0 ! $pdffilename = "clock.pdf"; $radius = 200; $margin = 20; - $pagecount = 190; $fp = fopen($pdffilename, "w"); $pdf = pdf_open($fp); pdf_set_info_creator($pdf, "pdf_clock.php3"); ! pdf_set_info_author($pdf, "Uwe Steinmann"); ! pdf_set_info_title($pdf, "Analog Clock"); ! while($pagecount-- > 0) { ! pdf_begin_page($pdf, 2 * ($radius + $margin), 2 * ($radius + $margin)); ! ! pdf_set_transition($pdf, 4); /* wipe */

! pdf_set_duration($pdf, 0.5); ! ! pdf_translate($pdf, $radius + $margin, $radius + $margin); ! pdf_save($pdf); ! pdf_setrgbcolor($pdf, 0.0, 0.0, 1.0); ! ! /* minute strokes */ ! pdf_setlinewidth($pdf, 2.0); ! for ($alpha = 0; $alpha < 360; $alpha += 6) ! { ! pdf_rotate($pdf, 6.0); ! pdf_moveto($pdf, $radius, 0.0); ! pdf_lineto($pdf, $radius-$margin/3, 0.0); ! pdf_stroke($pdf); ! } ! pdf_restore($pdf); ! pdf_save($pdf); ! /* 5 minute strokes */ ! pdf_setlinewidth($pdf, 3.0); ! for ($alpha = 0; $alpha < 360; $alpha += 30) ! { pdf_rotate($pdf, 30.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin, 0.0); pdf_stroke($pdf); ! } ! ! $ltime = getdate(); ! ! /* draw hour hand */ ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['minutes']/60.0) + $ltime['hours'] - 3.0) * 30.0); ! pdf_moveto($pdf, -$radius/10, -$radius/20); ! pdf_lineto($pdf, $radius/2, 0.0); ! pdf_lineto($pdf, -$radius/10, $radius/20); ! pdf_closepath($pdf); ! pdf_fill($pdf); ! pdf_restore($pdf); ! ! /* draw minute hand */ ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['seconds']/60.0) + $ltime['minutes'] - 15.0) * 6.0); ! pdf_moveto($pdf, -$radius/10, -$radius/20); ! pdf_lineto($pdf, $radius * 0.8, 0.0); ! pdf_lineto($pdf, -$radius/10, $radius/20); ! pdf_closepath($pdf); ! pdf_fill($pdf); ! pdf_restore($pdf); ! ! /* draw second hand */ ! pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0); ! pdf_setlinewidth($pdf, 2); ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0)); ! pdf_moveto($pdf, -$radius/5, 0.0); ! pdf_lineto($pdf, $radius, 0.0); ! pdf_stroke($pdf); ! pdf_restore($pdf); ! /* draw little circle at center */ ! pdf_circle($pdf, 0, 0, $radius/30); ! pdf_fill($pdf); ! pdf_restore($pdf); ! pdf_end_page($pdf); ! } $pdf = pdf_close($pdf); fclose($fp); --- 1,84 ---- <?php // This only works with pdflib 2.0 ! $pdffilename = "pdfclock_php.pdf"; $radius = 200; $margin = 20; $fp = fopen($pdffilename, "w"); $pdf = pdf_open($fp); pdf_set_info_creator($pdf, "pdf_clock.php3"); ! pdf_set_info_author($pdf, "Uwe Steinmann (modified for pdflib 2.01 by Simon Greaves)"); ! pdf_set_info_title($pdf, "PDF clock (PHP)"); ! pdf_begin_page($pdf, 2 * ($radius + $margin), 2 * ($radius + $margin)); ! ! pdf_translate($pdf, $radius + $margin, $radius + $margin); ! pdf_setrgbcolor($pdf, 0.0, 0.0, 1.0); ! pdf_save($pdf); ! ! /* minute strokes */ ! pdf_setlinewidth($pdf, 2.0); ! for ($alpha = 0; $alpha < 360; $alpha += 6) ! { ! pdf_rotate($pdf, 6.0); ! pdf_moveto($pdf, $radius, 0.0); ! pdf_lineto($pdf, $radius-$margin/3, 0.0); ! pdf_stroke($pdf); ! } ! pdf_restore($pdf); ! pdf_save($pdf); ! /* 5 minute strokes */ ! pdf_setlinewidth($pdf, 3.0); ! for ($alpha = 0; $alpha < 360; $alpha += 30) ! { pdf_rotate($pdf, 30.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin, 0.0);

pdf_stroke($pdf); ! } ! $ltime = getdate(); ! /* draw hour hand */ ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['minutes']/60.0) + $ltime['hours'] - 3.0) * 30.0); ! pdf_moveto($pdf, -$radius/10, -$radius/20); ! pdf_lineto($pdf, $radius/2, 0.0); ! pdf_lineto($pdf, -$radius/10, $radius/20); ! pdf_closepath($pdf); ! pdf_fill($pdf); ! pdf_restore($pdf); ! ! /* draw minute hand */ ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['seconds']/60.0) + $ltime['minutes'] - 15.0) * 6.0); ! pdf_moveto($pdf, -$radius/10, -$radius/20); ! pdf_lineto($pdf, $radius * 0.8, 0.0); ! pdf_lineto($pdf, -$radius/10, $radius/20); ! pdf_closepath($pdf); ! pdf_fill($pdf); ! pdf_restore($pdf); ! ! /* draw second hand */ ! pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0); ! pdf_setlinewidth($pdf, 2); ! pdf_save($pdf); ! pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0)); ! pdf_moveto($pdf, -$radius/5, 0.0); ! pdf_lineto($pdf, $radius, 0.0); ! pdf_stroke($pdf); ! pdf_restore($pdf); ! ! /* draw little circle at center */ ! pdf_circle($pdf, 0, 0, $radius/30);

! pdf_fill($pdf); ! ! pdf_restore($pdf); ! pdf_end_page($pdf); $pdf = pdf_close($pdf); fclose($fp);

8<------------------------------------------------------------------

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>