예제 #1
0
파일: pdflib.php 프로젝트: linuxwhy/tiki-1
 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);
     }
 }
예제 #2
0
 function rect($x, $y, $w, $h)
 {
     pdf_rect($this->pdf, $x, $y, $w, $h);
 }
예제 #3
0
 /**
  * Draw a rectangle
  *
  * Parameter array:
  * 'x0': int X start point
  * 'y0': int Y start point
  * 'x1': int X end point
  * 'y1': int Y end point
  * 'fill': mixed [optional] The fill color
  * 'line': mixed [optional] The line color
  * @param array $params Parameter array
  */
 function rectangle($params)
 {
     $x0 = $this->_getX($params['x0']);
     $y0 = $this->_getY($params['y0']);
     $x1 = $this->_getX($params['x1']);
     $y1 = $this->_getY($params['y1']);
     $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) {
         pdf_rect($this->_pdf, $this->_getX(min($x0, $x1)), $this->_getY(max($y0, $y1)), abs($x1 - $x0), abs($y1 - $y0));
         if ($line && $fill) {
             pdf_fill_stroke($this->_pdf);
         } elseif ($line) {
             pdf_stroke($this->_pdf);
         } elseif ($fill) {
             pdf_fill($this->_pdf);
         }
     }
     parent::rectangle($params);
 }
예제 #4
0
pdf_continue_text($pdf, '1 Calle Pequena');
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);
예제 #5
0
// draw the bar chart
$x = 80;
$y = 520;
$w = 40;
// the data and color for each column
$data = array('120', '160', '300', '240');
$color = array('#4EC3BC', '#DAA876', '#E29CC8', '#FDE0C6');
// get into some meat now, cheese for vegetarians;
for ($i = 0; $i < count($data); $i++) {
    // calculate the height of the bar
    $y_ht = $data[$i] / max($data) * 100;
    // set the color for each bar
    list($r, $g, $b) = hex2rgb($color[$i]);
    pdf_setcolor($pdf, "fill", "rgb", $r, $g, $b, 0);
    // draw the bar
    pdf_rect($pdf, $x, $y, $w, $y_ht);
    pdf_fill_stroke($pdf);
    // write the bar label
    pdf_setcolor($pdf, "fill", "rgb", 0, 0, 0, 0);
    pdf_setfont($pdf, $font, 10);
    pdf_show_xy($pdf, $data[$i], $x + 12, $y - 16);
    // go to the next bar
    $x = $x + $w + 40;
}
// done
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
// send it to browser
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=pdf_example3.pdf");
예제 #6
0
 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;
     }
 }
 $inset = 20;
 // space between border and page edge
 $border = 10;
 // width of main border line
 $inner = 2;
 // gap within the border
 //draw outer border
 pdf_rect($pdf, $inset - $inner, $inset - $inner, $width - 2 * ($inset - $inner), $height - 2 * ($inset - $inner));
 pdf_stroke($pdf);
 //draw main border $border points wide
 pdf_setlinewidth($pdf, $border);
 pdf_rect($pdf, $inset + $border / 2, $inset + $border / 2, $width - 2 * ($inset + $border / 2), $height - 2 * ($inset + $border / 2));
 pdf_stroke($pdf);
 pdf_setlinewidth($pdf, 1.0);
 // draw inner border
 pdf_rect($pdf, $inset + $border + $inner, $inset + $border + $inner, $width - 2 * ($inset + $border + $inner), $height - 2 * ($inset + $border + $inner));
 pdf_stroke($pdf);
 // add heading
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 48);
 }
 $startx = ($width - pdf_stringwidth($pdf, 'PHP Certification', $font, '12')) / 2;
 pdf_show_xy($pdf, 'PHP Certification', $startx, 490);
 // add text
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 26);
 }
 $startx = 70;
 pdf_show_xy($pdf, 'This is to certify that:', $startx, 430);
예제 #8
0
pdf_set_info($pdf, "Title", "www.nijman.de");
pdf_set_info($pdf, "Creator", "*****@*****.**");
pdf_set_info($pdf, "Subject", "pdf-stuff");
###########################################
# CREATE A SEPARATE PAGE FOR EACH STUDENT #
###########################################
$query = mysql_query("SELECT studentid, fname, mi, lname FROM students ORDER BY UPPER(lname)");
while ($student = mysql_fetch_row($query)) {
    pdf_begin_page($pdf, 595, 842);
    $TimesHeader = pdf_findfont($pdf, "Times-Bold", "host");
    $body = pdf_findfont($pdf, "Helvetica", "host");
    $bodybold = pdf_findfont($pdf, "Helvetica-Bold", "host");
    // Outline rectangle
    pdf_setlinewidth($pdf, 0.5);
    //make the border of the rectangle a bit wider
    pdf_rect($pdf, 50, 200, 495, 500);
    //draw the rectangle
    pdf_stroke($pdf);
    //stroke the path with the current color(not yet :-)) and line width
    ##############
    #  TOP TEXT  #
    ##############
    // Title //
    pdf_setfont($pdf, $TimesHeader, 30);
    pdf_show_xy($pdf, "Ray High School", 50, 760);
    // Student's Name //
    pdf_setfont($pdf, $body, 12);
    pdf_show_xy($pdf, "Student: {$student['1']} {$student['2']}. {$student['3']}", 50, 725);
    // Line Under Student's Name //
    pdf_moveto($pdf, 95, 722);
    pdf_lineto($pdf, 250, 722);