function restore()
 {
     pdf_restore($this->pdf);
 }
示例#2
0
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);
/* DONE */
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
// hides "Generating ..." message:
echo "<script language='JavaScript'>document.getElementById('loading').style.display = 'none';</script>";
if (!file_exists($file)) {
    ?>
    <h2 style="color: red">Error occured: file <?php 
    echo $file;
    ?>
 does not exist!</h2>
<?php 
}
?>
<?php

$p = PDF_new();
PDF_open_file($p);
$im = pdf_open_jpeg($p, "php-big.jpg");
$template = pdf_begin_template($p, 595, 842);
pdf_save($p);
pdf_place_image($p, $im, 4, 803, 0.25);
pdf_place_image($p, $im, 525, 803, 0.25);
pdf_moveto($p, 0, 795);
pdf_lineto($p, 595, 795);
pdf_stroke($p);
$font = PDF_findfont($p, "Times-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
pdf_show_xy($p, "PDF Template Example", 100, 807);
pdf_restore($p);
pdf_end_template($p);
pdf_close_image($p, $im);
PDF_begin_page($p, 595, 842);
pdf_place_image($p, $template, 0, 0, 1.0);
PDF_end_page($p);
PDF_begin_page($p, 595, 842);
pdf_place_image($p, $template, 0, 0, 1.0);
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;
示例#4
0
 function _bullet(&$bullet)
 {
     $type = '';
     $this->pdf_cy = pdf_get_value($this->pdf, "texty", null);
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     $height = 10;
     $txt = strip_markups($bullet->text);
     pdf_save($this->pdf);
     pdf_translate($this->pdf, 0, $this->pdf_y);
     pdf_scale($this->pdf, 1, -1);
     pdf_set_font($this->pdf, $this->pdf_font, 12, 'winansi');
     $leading = pdf_get_value($this->pdf, "leading", null);
     $inc = $leading;
     while (pdf_show_boxed($this->pdf, $txt, $this->pdf_cx + 30, $this->pdf_y - $this->pdf_cy, $this->pdf_x - 2 * ($this->pdf_cx + 20), $height, 'left', 'blind')) {
         $height += $inc;
     }
     pdf_restore($this->pdf);
     //clean up eols so we get a nice pdf output
     if (strstr($txt, "\r\n")) {
         $eol = "\r\n";
     } elseif (strstr($txt, "\r")) {
         $eol = "\r";
     } else {
         $eol = "\n";
     }
     $txt = str_replace($eol, " ", $txt);
     $txt = str_replace("  ", " ", $txt);
     if ($this->pdf_cy + $height > $this->pdf_y - 40) {
         $this->my_pdf_page_number($this->pdf, $this->pdf_x, $this->pdf_y);
         $this->my_new_pdf_end_page($this->pdf);
         $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
         $this->pdf_cx = 40;
         $this->pdf_cy = 60;
     }
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     if ($bullet->type == 'speaker') {
         pdf_setcolor($this->pdf, 'fill', 'rgb', 1, 0, 0, null);
     }
     if (!empty($bullet->start)) {
         if (is_numeric($bullet->start)) {
             $this->objs[$this->coid]->num = (int) $bullet->start;
         } else {
             $this->objs[$this->coid]->alpha = $bullet->start;
         }
     }
     if (!empty($bullet->type)) {
         $type = $bullet->type;
     } else {
         if (!empty($this->objs[$this->coid]->type)) {
             $type = $this->objs[$this->coid]->type;
         }
     }
     switch ($type) {
         case 'numbered':
         case 'number':
         case 'decimal':
             $symbol = ++$this->objs[$this->coid]->num . '.';
             $pdf_cx_height = 30;
             break;
         case 'no-bullet':
         case 'none':
             $symbol = '';
             $pdf_cx_height = 20;
             break;
         case 'alpha':
             $symbol = $this->objs[$this->coid]->alpha++ . '.';
             break;
         case 'ALPHA':
             $symbol = strtoupper($this->objs[$this->coid]->alpha++) . '.';
             $pdf_cx_height = 30;
             break;
         case 'asterisk':
             $symbol = '*';
             $pdf_cx_height = 20;
             break;
         case 'hyphen':
             $symbol = '-';
             $pdf_cx_height = 20;
             break;
         default:
             $symbol = 'o';
             $pdf_cx_height = 20;
             break;
     }
     pdf_show_xy($this->pdf, $symbol, $this->pdf_cx + 20 + $bullet->level * 10, $this->pdf_cy + $leading - 1);
     pdf_show_boxed($this->pdf, $txt, $this->pdf_cx + 40 + $bullet->level * 10, $this->pdf_cy - $height, $this->pdf_x - 2 * ($this->pdf_cx + 20), $height, 'left', null);
     pdf_continue_text($this->pdf, "\n");
     $this->pdf_cy = pdf_get_value($this->pdf, "texty", null);
     pdf_set_text_pos($this->pdf, $this->pdf_cx, $this->pdf_cy - $leading / 2);
     pdf_setcolor($this->pdf, 'fill', 'rgb', 0, 0, 0, null);
 }