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); } }
/** * 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); }
function add_poll($name, $opts, $ttl_votes) { $this->y = pdf_get_value($this->pdf, 'texty', 0) - 3; pdf_set_text_pos($this->pdf, $this->wmargin, $this->y - 3); pdf_setfont($this->pdf, $this->fonts['Courier-Bold'], 20); pdf_continue_text($this->pdf, $name); pdf_setfont($this->pdf, $this->fonts['Courier-Bold'], 16); pdf_show($this->pdf, '(total votes: ' . $ttl_votes . ')'); $this->draw_line(); $ttl_w = round($this->pw * 0.66); $ttl_h = 20; $p1 = floor($ttl_w / 100); $this->y -= 10; /* avoid /0 warnings and safe to do, since we'd be multiplying 0 since there are no votes */ if (!$ttl_votes) { $ttl_votes = 1; } pdf_setfont($this->pdf, $this->fonts['Helvetica-Bold'], 14); foreach ($opts as $o) { $w1 = $p1 * ($o['votes'] / $ttl_votes * 100); $h1 = $this->y - $ttl_h; pdf_setcolor($this->pdf, 'both', 'rgb', 0.92, 0.92, 0.92); pdf_rect($this->pdf, $this->wmargin, $h1, $w1, $ttl_h); pdf_fill_stroke($this->pdf); pdf_setcolor($this->pdf, 'both', 'rgb', 0, 0, 0); pdf_show_xy($this->pdf, $o['name'] . "\t\t" . $o['votes'] . '/(' . round($o['votes'] / $ttl_votes * 100) . '%)', $this->wmargin + 2, $h1 + 3); $this->y = $h1 - 10; } }
pdf_continue_text($pdf, 'Cuidad Perdida, Puno 123'); pdf_set_font($pdf, "Helvetica", 10, winansi); pdf_show_xy($pdf, 'Terminos: Pago Completo 15 horas', 150, $y - 100); pdf_continue_text($pdf, 'Apt. Postal: 12345'); pdf_set_font($pdf, "Helvetica-Bold", 30, winansi); pdf_show_xy($pdf, "* F A C T U R A *", $x - 250, $y - 112); pdf_setcolor($pdf, 'fill', 'gray', 0.9, 0, 0, 0); pdf_rect($pdf, 20, 80, $x - 40, $y - 212); pdf_fill_stroke($pdf); $offset = 184; $i = 0; while ($y - $offset > 80) { pdf_setcolor($pdf, 'fill', 'gray', $i % 2 ? 0.8 : 1, 0, 0, 0); pdf_setcolor($pdf, 'stroke', 'gray', $i % 2 ? 0.8 : 1, 0, 0, 0); pdf_rect($pdf, 21, $y - $offset, $x - 42, 24); pdf_fill_stroke($pdf); $i++; $offset += 24; } pdf_setcolor($pdf, 'fill', 'gray', 0, 0, 0, 0); pdf_setcolor($pdf, 'stroke', 'gray', 0, 0, 0, 0); pdf_moveto($pdf, 20, $y - 160); pdf_lineto($pdf, $x - 20, $y - 160); pdf_stroke($pdf); pdf_moveto($pdf, $x - 140, $y - 160); pdf_lineto($pdf, $x - 140, 80); pdf_stroke($pdf); pdf_set_font($pdf, "Times-Bold", 18, winansi); pdf_show_xy($pdf, "Articulo", 30, $y - 150); pdf_show_xy($pdf, "Precio", $x - 100, $y - 150); pdf_set_font($pdf, "Times-Italic", 15, winansi);
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); } }