Exemple #1
0
PDF_moveto($p, -$RADIUS / 10, -$RADIUS / 20);
PDF_lineto($p, $RADIUS * 0.8, 0.0);
PDF_lineto($p, -$RADIUS / 10, $RADIUS / 20);
PDF_closepath($p);
PDF_fill($p);
PDF_restore($p);
/* draw second hand */
PDF_setcolor($p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0);
PDF_setlinewidth($p, 2);
PDF_save($p);
PDF_rotate($p, -(($ltime['seconds'] - 15.0) * 6.0));
PDF_moveto($p, -$RADIUS / 5, 0.0);
PDF_lineto($p, $RADIUS, 0.0);
PDF_stroke($p);
PDF_restore($p);
/* draw little circle at center */
PDF_circle($p, 0, 0, $RADIUS / 30);
PDF_fill($p);
PDF_restore($p);
PDF_end_page($p);
/* close page           */
PDF_close($p);
/* close PDF document	*/
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=pdfclock.pdf");
print $buf;
PDF_delete($p);
/* delete the PDFlib object */
<?php

$p = PDF_new();
PDF_open_file($p);
$im = pdf_open_png($p, "fr-flag.png");
$pattern = pdf_begin_pattern($p, 21, 14, 25, 18, 1);
pdf_save($p);
pdf_place_image($p, $im, 0, 0, 1);
pdf_restore($p);
pdf_end_pattern($p);
pdf_close_image($p, $im);
PDF_begin_page($p, 595, 842);
PDF_setcolor($p, "fill", "pattern", $pattern);
PDF_setcolor($p, "stroke", "pattern", $pattern);
pdf_setlinewidth($p, 30.0);
PDF_circle($p, 200, 680, 120);
PDF_stroke($p);
PDF_end_page($p);
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=gra2.pdf");
echo $buf;
PDF_delete($p);
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
PDF_setcolor($p, "fill", "rgb", 1.0, 0.8, 0.1);
PDF_moveto($p, 150, 750);
PDF_lineto($p, 450, 750);
PDF_lineto($p, 100, 800);
PDF_curveto($p, 80, 500, 70, 550, 250, 650);
PDF_closepath($p);
PDF_fill_stroke($p);
// Circle
PDF_setcolor($p, "fill", "rgb", 0.8, 0.5, 0.8);
PDF_circle($p, 400, 600, 75);
PDF_fill_stroke($p);
// Funky Arc
PDF_setcolor($p, "fill", "rgb", 0.8, 0.5, 0.5);
PDF_moveto($p, 200, 600);
PDF_arc($p, 300, 600, 50, 0, 120);
PDF_closepath($p);
PDF_fill_stroke($p);
// Dashed rectangle
PDF_setcolor($p, "stroke", "rgb", 0.3, 0.8, 0.3);
PDF_setdash($p, 4, 6);
PDF_rect($p, 50, 500, 500, 300);
PDF_stroke($p);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
 function Shape($tipo, $x, $y, $largura = 0, $altura = 0, $linha = 0.001, $color = "#000000", $color2 = "#FFFFFF")
 {
     $this->SetLine($linha);
     $this->SetBoth($color);
     $this->SetFill($color2);
     switch ($tipo) {
         case 'ret':
             PDF_rect($this->pdf, $x, $y, $largura, $altura);
             break;
         case 'elipse':
             PDF_circle($this->pdf, $x, $y, $largura);
             break;
     }
     PDF_fill_stroke($this->pdf);
     if ($this->depurar) {
         echo '<b>PDF:</b> Adicionado um shape.<br>';
     }
 }
<?php

$p = PDF_new();
PDF_open_file($p);
$im = pdf_open_png($p, "wa.png");
$pattern = pdf_begin_pattern($p, 81, 41, 81, 41, 1);
pdf_save($p);
pdf_place_image($p, $im, 0, 0, 1);
pdf_restore($p);
pdf_end_pattern($p);
pdf_close_image($p, $im);
PDF_begin_page($p, 595, 842);
PDF_setcolor($p, "fill", "pattern", $pattern);
PDF_setcolor($p, "stroke", "pattern", $pattern);
pdf_setlinewidth($p, 50.0);
PDF_circle($p, 200, 680, 140);
PDF_stroke($p);
PDF_end_page($p);
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=gra2.pdf");
echo $buf;
PDF_delete($p);