See also the PDFlib extension documentation.
?php $radius = 200; $margin = 20; $pagecount = 40; $pdf = cpdf_open(0); cpdf_set_creator($pdf, "pdf_clock.php3"); cpdf_set_title($pdf, "Analog Clock"); while($pagecount- - 0) {cpdf_page_init($pdf, $pagecount+1, 0, 2 * ($radius + $margin), 2 * ($radius + $margin), 1.0); cpdf_set_page_animation($pdf, 4, 0.5, 0, 0, 0); / * wipe * / cpdf_translate($pdf, $radius + $margin, $radius + $margin); cpdf_save($pdf); cpdf_setrgbcolor($pdf, 0.0, 0.0, 1.0); / * indications des minutes * / cpdf_setlinewidth($pdf, 2.0); for ($alpha = 0; $alpha 360; $alpha += 6) {cpdf_rotate($pdf, 6.0); cpdf_moveto($pdf, $radius, 0.0); cpdf_lineto($pdf, $radius-$margin / 3, 0.0); cpdf_stroke($pdf);} cpdf_restore($pdf); cpdf_save($pdf); / * Indications des 5 minutes * / cpdf_setlinewidth($pdf, 3.0); for ($alpha = 0; $alpha 360; $alpha += 30) {cpdf_rotate($pdf, 30.0); cpdf_moveto($pdf, $radius, 0.0); cpdf_lineto($pdf, $radius-$margin, 0.0); cpdf_stroke($pdf);} $ltime = getdate(); / * aiguille des heures * / cpdf_save($pdf); cpdf_rotate($pdf, -(($ltime['minutes'] / 60.0) + $ltime['hours'] - 3.0) * 30.0); cpdf_moveto($pdf, -$radius / 10, -$radius / 20); cpdf_lineto($pdf, $radius / 2, 0.0); cpdf_lineto($pdf, -$radius / 10, $radius / 20); cpdf_closepath($pdf); cpdf_fill($pdf); cpdf_restore($pdf); / * aiguille des minutes * / cpdf_save($pdf); cpdf_rotate($pdf, -(($ltime['seconds'] / 60.0) + $ltime['minutes'] - 15.0) * 6.0); cpdf_moveto($pdf, -$radius / 10, -$radius / 20); cpdf_lineto($pdf, $radius * 0.8, 0.0); cpdf_lineto($pdf, -$radius / 10, $radius / 20); cpdf_closepath($pdf); cpdf_fill($pdf); cpdf_restore($pdf); / * aiguille des secondes * / cpdf_setrgbcolor($pdf, 1.0, 0.0, 0.0); cpdf_setlinewidth($pdf, 2); cpdf_save($pdf); cpdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0)); cpdf_moveto($pdf, -$radius / 5, 0.0); cpdf_lineto($pdf, $radius, 0.0); cpdf_stroke($pdf); cpdf_restore($pdf); / * Un petit cercle au centre * / cpdf_circle($pdf, 0, 0, $radius / 30); cpdf_fill($pdf); cpdf_restore($pdf); cpdf_finalize_page($pdf, $pagecount+1);} cpdf_finalize($pdf); header("Content-type: application / pdf"); cpdf_output_buffer($pdf); cpdf_close($pdf);?