<?php $p = PDF_new(); PDF_open_file($p); PDF_set_info($p, "Creator", "coords.php"); PDF_set_info($p, "Author", "Rasmus Lerdorf"); PDF_set_info($p, "Title", "Coordinate Test (PHP)"); PDF_begin_page($p, 595, 842); PDF_translate($p, 0, 842); // Move Origin PDF_scale($p, 1, -1); // Reflect across horizontal axis PDF_set_value($p, "horizscaling", -100); // Mirror $font = PDF_findfont($p, "Helvetica-Bold", "host", 0); PDF_setfont($p, $font, -38.0); PDF_show_xy($p, "Top Left", 10, 40); PDF_end_page($p); PDF_set_parameter($p, "openaction", "fitpage"); PDF_close($p); $buf = PDF_get_buffer($p); $len = strlen($buf); Header("Content-type:application/pdf"); Header("Content-Length:{$len}"); Header("Content-Disposition:inline; filename=coords.pdf"); echo $buf; PDF_delete($p);
$RADIUS = 200.0; $MARGIN = 20.0; $p = PDF_new(); /* create a new PDFlib object */ /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_open_file($p, "") == 0) { die("Error: " . PDF_get_errmsg($p)); } /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, "Creator", "pdfclock.php"); PDF_set_info($p, "Author", "Rainer Schaaf"); PDF_set_info($p, "Title", "PDF clock (PHP)"); /* start a new page */ PDF_begin_page($p, 2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN)); PDF_translate($p, $RADIUS + $MARGIN, $RADIUS + $MARGIN); PDF_setcolor($p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0); PDF_save($p); /* minute strokes */ PDF_setlinewidth($p, 2.0); for ($alpha = 0; $alpha < 360; $alpha += 6) { PDF_rotate($p, 6.0); PDF_moveto($p, $RADIUS, 0.0); PDF_lineto($p, $RADIUS - $MARGIN / 3, 0.0); PDF_stroke($p); } PDF_restore($p); PDF_save($p); /* 5 minute strokes */ PDF_setlinewidth($p, 3.0); for ($alpha = 0; $alpha < 360; $alpha += 30) {