Exemplo n.º 1
0
 function drawRectangle($left, $top, $right, $bottom, $style)
 {
     $this->_convertPosition($left, $top);
     $this->_convertPosition($right, $bottom);
     pdf_setcolor($this->pdf, 'stroke', $style['line'][0], $style['line'][1], $style['line'][2], $style['line'][3], $style['line'][4]);
     if (isset($style['fill'])) {
         pdf_setcolor($this->pdf, 'fill', $style['fill'][0], $style['fill'][1], $style['fill'][2], $style['fill'][3], $style['fill'][4]);
     }
     pdf_setlinewidth($this->pdf, $style['line-width']);
     pdf_rect($this->pdf, $left, $top, $right - $left, $bottom - $top);
     if (isset($style['fill'])) {
         pdf_fill_stroke($this->pdf);
     } else {
         pdf_stroke($this->pdf);
     }
 }
Exemplo n.º 2
0
 function stroke()
 {
     pdf_stroke($this->pdf);
 }
Exemplo n.º 3
0
 /**
  * Draw an ellipse
  *
  * Parameter array:
  * 'x': int X center point
  * 'y': int Y center point
  * 'rx': int X radius
  * 'ry': int Y radius
  * 'fill': mixed [optional] The fill color
  * 'line': mixed [optional] The line color
  * @param array $params Parameter array
  */
 function ellipse($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $rx = $this->_getX($params['rx']);
     $ry = $this->_getY($params['ry']);
     $fillColor = isset($params['fill']) ? $params['line'] : false;
     $lineColor = isset($params['line']) ? $params['line'] : false;
     $line = $this->_setLineStyle($lineColor);
     $fill = $this->_setFillStyle($fillColor);
     if ($line || $fill) {
         if ($rx == $ry) {
             pdf_circle($this->_pdf, $this->_getX($x), $this->_getY($y), $rx);
         } else {
             pdf_moveto($this->_pdf, $this->_getX($x - $rx), $this->_getY($y));
             pdf_curveto($this->_pdf, $this->_getX($x - $rx), $this->_getY($y), $this->_getX($x - $rx), $this->_getY($y - $ry), $this->_getX($x), $this->_getY($y - $ry));
             pdf_curveto($this->_pdf, $this->_getX($x), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y));
             pdf_curveto($this->_pdf, $this->_getX($x + $rx), $this->_getY($y), $this->_getX($x + $rx), $this->_getY($y + $ry), $this->_getX($x), $this->_getY($y + $ry));
             pdf_curveto($this->_pdf, $this->_getX($x), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y));
         }
         if ($line && $fill) {
             pdf_fill_stroke($this->_pdf);
         } elseif ($line) {
             pdf_stroke($this->_pdf);
         } elseif ($fill) {
             pdf_fill($this->_pdf);
         }
     }
     parent::ellipse($params);
 }
Exemplo n.º 4
0
<?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;
Exemplo n.º 5
0
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);
/* 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;
Exemplo n.º 6
0
 function _slide(&$slide)
 {
     global $pres;
     $currentPres = $_SESSION['currentPres'];
     $p = $this->objs[1];
     $middle = (int) ($this->pdf_y / 2) - 40;
     $this->pdf_cy = 25;
     // top-margin
     $this->pdf_cx = 40;
     if ($this->objs[1]->template == 'titlepage') {
         $p = $pres;
         $loc = $middle - 80 * (!empty($p->title) + !empty($p->event) + !empty($p->date) + (!empty($p->speaker) || !empty($p->email)) + !empty($p->url) + !empty($p->subtitle)) / 2;
         if (!empty($p->title)) {
             pdf_set_font($this->pdf, $this->pdf_font, -36, 'winansi');
             pdf_show_boxed($this->pdf, $p->title, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         }
         if (!empty($p->subtitle)) {
             $loc += 50;
             pdf_set_font($this->pdf, $this->pdf_font, -22, 'winansi');
             pdf_show_boxed($this->pdf, $p->subtitle, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         }
         if (!empty($p->event)) {
             $loc += 80;
             pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
             pdf_show_boxed($this->pdf, $p->event, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         }
         if (!empty($p->date) && !empty($p->location)) {
             $loc += 80;
             pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
             pdf_show_boxed($this->pdf, $p->date . '. ' . $p->location, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         } else {
             if (!empty($p->date)) {
                 $loc += 80;
                 pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
                 pdf_show_boxed($this->pdf, $p->date, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
             } else {
                 if (!empty($p->location)) {
                     $loc += 80;
                     pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
                     pdf_show_boxed($this->pdf, $p->location, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
                 }
             }
         }
         if (!empty($p->speaker) && !empty($p->email)) {
             $loc += 80;
             pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
             pdf_show_boxed($this->pdf, $p->speaker . ' <' . $p->email . '>', 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         } else {
             if (!empty($p->speaker)) {
                 $loc += 80;
                 pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
                 pdf_show_boxed($this->pdf, $p->speaker, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
             } else {
                 if (!empty($p->email)) {
                     $loc += 80;
                     pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
                     pdf_show_boxed($this->pdf, ' <' . $p->email . '>', 10, $loc, $this->pdf_x - 20, 40, 'center', null);
                 }
             }
         }
         if (!empty($p->url)) {
             $loc += 80;
             pdf_set_font($this->pdf, $this->pdf_font, -30, 'winansi');
             pdf_show_boxed($this->pdf, $p->url, 10, $loc, $this->pdf_x - 20, 40, 'center', null);
         }
         if (!empty($p->copyright)) {
             pdf_moveto($this->pdf, 60, $this->pdf_y - 60);
             pdf_lineto($this->pdf, $this->pdf_x - 60, $this->pdf_y - 60);
             pdf_stroke($this->pdf);
             pdf_set_font($this->pdf, $this->pdf_font, -10, 'winansi');
             $fnt = pdf_findfont($this->pdf, $this->pdf_font, 'winansi', 0);
             $x = (int) ($this->pdf_x / 2 - pdf_stringwidth($this->pdf, $p->copyright, $fnt, -10) / 2);
             $str = str_replace('(c)', chr(0xa9), $p->copyright);
             $str = str_replace('(R)', chr(0xae), $str);
             pdf_show_xy($this->pdf, $str, $x, $this->pdf_y - 45);
         }
         $this->page_index[$this->page_number] = 'titlepage';
     } else {
         // No header on the title page
         pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
         $fnt = pdf_findfont($this->pdf, $this->pdf_font, 'winansi', 0);
         pdf_show_boxed($this->pdf, "Slide {$this->slideNum}/{$this->maxSlideNum}", $this->pdf_cx, $this->pdf_cy, $this->pdf_x - 2 * $this->pdf_cx, 1, 'left', null);
         if (isset($p->date)) {
             $this->d = $this->date;
         } else {
             $this->d = strftime("%B %e %Y");
         }
         $w = pdf_stringwidth($this->pdf, $this->d, $fnt, -12);
         pdf_show_boxed($this->pdf, $this->d, 40, $this->pdf_cy, $this->pdf_x - 2 * $this->pdf_cx, 1, 'right', null);
         pdf_set_font($this->pdf, $this->pdf_font, -24, 'winansi');
         pdf_show_boxed($this->pdf, strip_markups($slide->title), 40, $this->pdf_cy, $this->pdf_x - 2 * $this->pdf_cx, 1, 'center', null);
         $this->page_index[$this->page_number] = strip_markups($slide->title);
     }
     $this->pdf_cy += 30;
     if ($this->slideNum) {
         pdf_moveto($this->pdf, 40, $this->pdf_cy);
         pdf_lineto($this->pdf, $this->pdf_x - 40, $this->pdf_cy);
         pdf_stroke($this->pdf);
     }
     $this->pdf_cy += 20;
     pdf_set_text_pos($this->pdf, $this->pdf_cx, $this->pdf_cy);
 }
Exemplo n.º 7
0
 function end_message()
 {
     $y = pdf_get_value($this->pdf, 'texty', 0) - 10;
     pdf_moveto($this->pdf, $this->wmargin, $y);
     pdf_lineto($this->pdf, $this->pw - $this->wmargin, $y);
     pdf_moveto($this->pdf, $this->wmargin, $y - 3);
     pdf_lineto($this->pdf, $this->pw - $this->wmargin, $y - 3);
     pdf_stroke($this->pdf);
     pdf_set_text_pos($this->pdf, $this->wmargin, $y - 20);
 }
function draw_star($centerx, $centery, $points, $radius, $point_size, $pdf, $filled)
{
    $inner_radius = $radius - $point_size;
    for ($i = 0; $i <= $points * 2; $i++) {
        $angle = $i * 2 * pi() / ($points * 2);
        if ($i % 2) {
            $x = $radius * cos($angle) + $centerx;
            $y = $radius * sin($angle) + $centery;
        } else {
            $x = $inner_radius * cos($angle) + $centerx;
            $y = $inner_radius * sin($angle) + $centery;
        }
        if ($i == 0) {
            pdf_moveto($pdf, $x, $y);
        } else {
            if ($i == $points * 2) {
                pdf_closepath($pdf);
            } else {
                pdf_lineto($pdf, $x, $y);
            }
        }
    }
    if ($filled) {
        pdf_fill_stroke($pdf);
    } else {
        pdf_stroke($pdf);
    }
}