Пример #1
0
 function begin_page($title)
 {
     pdf_begin_page($this->pdf, $this->pw, $this->ph);
     pdf_setlinewidth($this->pdf, 1);
     $ttl = $title;
     if ($this->pg_num) {
         $this->pg_num++;
         $ttl .= ' #' . $this->pg_num;
     } else {
         $this->pg_num = 1;
     }
     pdf_add_bookmark($this->pdf, $ttl);
     pdf_setfont($this->pdf, $this->fonts['Courier'], 12);
     pdf_set_text_pos($this->pdf, $this->wmargin, $this->ph - $this->hmargin);
     $this->pg_title = $title;
 }
Пример #2
0
 function drawPie($centerX, $centerY, $radius, $begin, $end, $style)
 {
     $this->_convertPosition($centerX, $centerY);
     $radius = $radius * min($this->width, $this->height);
     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_moveto($this->pdf, $centerX, $centerY);
     pdf_arc($this->pdf, $centerX, $centerY, $radius, $begin, $end);
     pdf_lineto($this->pdf, $centerX, $centerY);
     if (isset($style['fill'])) {
         pdf_closepath_fill_stroke($this->pdf);
     } else {
         pdf_closepath_stroke($this->pdf);
     }
 }
Пример #3
0
 function setlinewidth($x)
 {
     pdf_setlinewidth($this->pdf, $x);
 }
Пример #4
0
 /**
  * Get the PDF linestyle
  *
  * @param mixed $lineStyle The line style to return, false if the one
  *   explicitly set
  * @return bool True if set (so that a line should be drawn)
  * @access private
  */
 function _setLineStyle($lineStyle = false)
 {
     if ($lineStyle === false) {
         $lineStyle = $this->_lineStyle;
     }
     if ($lineStyle == 'transparent' || $lineStyle === false) {
         return false;
     }
     if (is_array($lineStyle)) {
         // TODO Implement linestyles in PDFlib (using pdf_setcolor(.., 'pattern'...); ?
         reset($lineStyle);
         $lineStyle = current($lineStyle);
     }
     $color = $this->_color($lineStyle);
     pdf_setlinewidth($this->_pdf, $this->_thickness);
     if ($this->_pdflib < 4) {
         pdf_setrgbcolor_stroke($this->_pdf, $color[0] / 255, $color[1] / 255, $color[2] / 255);
     } else {
         pdf_setcolor($this->_pdf, 'stroke', 'rgb', $color[0], $color[1], $color[2], 0);
     }
     return true;
 }
Пример #5
0
pdf_lineto($pdf, -$radius / 10, $radius / 20);
pdf_closepath($pdf);
pdf_fill($pdf);
pdf_restore($pdf);
/* draw minute hand */
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:
Пример #6
0
if (NJB_DEFAULT_CHARSET == 'UTF-8') {
    pdf_set_parameter($pdf, 'textformat', 'utf8');
}
pdf_set_info($pdf, 'Creator', 'netjukebox ' . NJB_VERSION);
pdf_set_info($pdf, 'Title', $album['artist'] . ' - ' . $album['album']);
$width = 210;
// A4
$height = 297;
// A4
$scale = 72 / 25.4;
// mm to dtp-point (1 point = 1/72 inch; 1 inch = 25.4 mm)
$hash_data = pdf_get_value($pdf, 'major', 0) . '-' . pdf_get_value($pdf, 'minor', 0) . '-' . NJB_VERSION;
$hash_data .= '-' . $album['artist'] . ' - ' . $album['album'] . '-' . $width . '-' . $height;
pdf_begin_page($pdf, $width * $scale, $height * $scale);
pdf_scale($pdf, $scale, $scale);
pdf_setlinewidth($pdf, 0.1);
//  +------------------------------------------------------------------------+
//  | PDF back cover                                                         |
//  +------------------------------------------------------------------------+
$x0 = 30;
$y0 = 22;
pdf_translate($pdf, $x0, $y0);
pdf_moveto($pdf, 0, -1);
pdf_lineto($pdf, 0, -11);
pdf_moveto($pdf, 6.5, -1);
pdf_lineto($pdf, 6.5, -11);
pdf_moveto($pdf, 144.5, -1);
pdf_lineto($pdf, 144.5, -11);
pdf_moveto($pdf, 151, -1);
pdf_lineto($pdf, 151, -11);
pdf_moveto($pdf, 0, 119);
Пример #7
0
<?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);
$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);
 pdf_begin_page($pdf, $width, $height);
 // draw our borders
 $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);
 }
Пример #10
0
pdf_open_file($pdf);
pdf_set_info($pdf, "Author", "Bob Nijman");
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 //