Esempio n. 1
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
PDF_moveto($p, 150, 750);
PDF_lineto($p, 450, 750);
PDF_lineto($p, 100, 800);
PDF_curveto($p, 80, 500, 70, 550, 250, 650);
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=gra1.pdf");
echo $buf;
PDF_delete($p);
 /**
  * Output the barcode
  *
  * Puts the barcode specified via settext() onto the PDF document.
  * The barcode is scaled to fit into the specified space.
  *
  * @param    float    $xpos     The left starting position
  * @param    float    $ypos     The top starting position
  * @param    float    $width    The width of the barcode
  * @param    float    $height   The height of the barcode
  *
  * @access   public
  */
 function putcode($xpos, $ypos, $width, $height)
 {
     switch ($this->type) {
         default:
         case '39':
             // code 39: narrow=4, wide=11, quiet=7
             $narrow = 4;
             $wide = 11;
             $quiet = 7;
             $convtable[0] = $narrow;
             $convtable[1] = $wide;
             $convtable[2] = $quiet;
             $text = $this->text;
             $codes = array();
             array_push($codes, $this->char2code39('START'));
             for ($i = 0; $i < strlen($text); $i++) {
                 array_push($codes, $this->char2code39(substr($text, $i, 1)));
             }
             array_push($codes, $this->char2code39('STOP'));
             $code = implode('2', $codes);
             // Total width is the sum of:
             // - Widths of the characters' barcode representation (plus
             //   start/stop characters)
             // - Widths of the blank spaces between them
             $fullwidth = (strlen($text) + 2) * (6 * $narrow + 3 * $wide) + (strlen($text) + 1) * $quiet;
             $basewidth = $width / $fullwidth;
             break;
         case '25i':
             $narrow = 1;
             $wide = 2;
             $convtable[0] = $narrow;
             $convtable[1] = $wide;
             $text = $this->text;
             // The length of the text must be even; if not, we
             // pad it with a leading "0"
             if (strlen($text) % 2 != 0) {
                 $text = "0" . $text;
             }
             $code = $this->char2code25i('START');
             for ($i = 0; $i < strlen($text); $i += 2) {
                 $code1 = $this->char2code25i(substr($text, $i, 1));
                 $code2 = $this->char2code25i(substr($text, $i + 1, 1));
                 // Interleaved code: Shake 'em up!
                 for ($j = 0; $j < 5; $j++) {
                     $code .= substr($code1, $j, 1);
                     $code .= substr($code2, $j, 1);
                 }
             }
             $code .= $this->char2code25i('STOP');
             // Total width is the sum of:
             // - Widths of the start/stop characters (6*narrow+1*wide)
             // - Widths of the characters' barcode representation
             $fullwidth = strlen($text) * (3 * $narrow + 2 * $wide) + 6 * $narrow + 1 * $wide;
             $basewidth = $width / $fullwidth;
             break;
         case '128a':
         case '128b':
         case '128c':
             $convtable[1] = 1;
             $convtable[2] = 2;
             $convtable[3] = 3;
             $convtable[4] = 4;
             $text = $this->text;
             switch ($this->type) {
                 case '128a':
                     $char2code128index = char2code128aindex;
                     break;
                 case '128b':
                     $char2code128index = char2code128bindex;
                     break;
                 case '128c':
                     $char2code128index = char2code128cindex;
                     // The length of the text must be even; if not, we
                     // pad it with a leading "0"
                     if (strlen($text) % 2 != 0) {
                         $text = "0" . $text;
                     }
                     break;
             }
             $checksum = 0;
             $index = $this->{$char2code128index}('START');
             $code = $this->code128table[$index];
             $checksum += $index;
             for ($i = 0; $i < strlen($text); $i++) {
                 if ($this->type == '128c') {
                     // 128c encodes two chars in one go
                     $index = $this->{$char2code128index}(substr($text, $i, 2));
                     $i++;
                 } else {
                     $index = $this->{$char2code128index}(substr($text, $i, 1));
                 }
                 $code .= $this->code128table[$index];
                 $checksum += ($i + 1) * $index;
             }
             // Calculate and output the code 128 checksum
             $checksum %= 103;
             $code .= $this->code128table[$checksum];
             $index = $this->{$char2code128index}('STOP');
             $code .= $this->code128table[$index];
             // Total width is the sum of:
             // - Widths of the start character's barcode representation (11)
             // - Widths of the text characters' barcode representation (11)
             // - Widths of the checksum character's barcode representation (11)
             // - Widths of the stop character's barcode representation (13)
             $fullwidth = (strlen($text) + 2) * 11 + 13;
             $basewidth = $width / $fullwidth;
             break;
     }
     $black = true;
     for ($i = 0; $i < strlen($code); $i++) {
         $barwidth = $convtable[$code[$i]] * $basewidth;
         if ($black) {
             PDF_setcolor($this->pdf, "both", "gray", 0, 0, 0, 0);
             PDF_setlinecap($this->pdf, 0);
             PDF_setlinewidth($this->pdf, $barwidth);
             PDF_moveto($this->pdf, $xpos + 0.5 * $barwidth, $ypos);
             PDF_lineto($this->pdf, $xpos + 0.5 * $barwidth, $ypos - $height);
             PDF_stroke($this->pdf);
         }
         $xpos += $barwidth;
         $black = !$black;
     }
     return 1;
 }
Esempio n. 3
0
PDF_restore($p);
/* draw minute hand */
PDF_save($p);
PDF_rotate($p, -($ltime['seconds'] / 60.0 + $ltime['minutes'] - 15.0) * 6.0);
PDF_moveto($p, -$RADIUS / 10, -$RADIUS / 20);
PDF_lineto($p, $RADIUS * 0.8, 0.0);
PDF_lineto($p, -$RADIUS / 10, $RADIUS / 20);
PDF_closepath($p);
PDF_fill($p);
PDF_restore($p);
/* draw second hand */
PDF_setcolor($p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0);
PDF_setlinewidth($p, 2);
PDF_save($p);
PDF_rotate($p, -(($ltime['seconds'] - 15.0) * 6.0));
PDF_moveto($p, -$RADIUS / 5, 0.0);
PDF_lineto($p, $RADIUS, 0.0);
PDF_stroke($p);
PDF_restore($p);
/* draw little circle at center */
PDF_circle($p, 0, 0, $RADIUS / 30);
PDF_fill($p);
PDF_restore($p);
PDF_end_page($p);
/* close page           */
PDF_close($p);
/* close PDF document	*/
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
 /**
  * Close the table on the current page
  *
  * Draws the bottom border, the vertical table border, the
  * column spacing border and creates a new page.
  *
  * @access   public
  */
 function endtable()
 {
     if (sizeof($this->rowbuffer) > 0) {
         $rowbuffer = $this->rowbuffer;
         $this->rowbuffer = array();
         $this->addrow($rowbuffer);
     }
     if ($this->topborderwidth > 0) {
         if ($this->topbordercolor !== false) {
             PDF_setlinecap($this->pdf, 0);
             PDF_setlinewidth($this->pdf, $this->bottomborderwidth);
             $this->setcolor($this->bottombordercolor);
             PDF_moveto($this->pdf, $this->firstxpos, $this->ypos - 0.5 * $this->bottomborderwidth);
             PDF_lineto($this->pdf, $this->firstxpos + $this->width, $this->ypos - 0.5 * $this->bottomborderwidth);
             PDF_stroke($this->pdf);
         }
         $this->ypos -= $this->bottomborderwidth;
     }
     // When scheduled via setverttableborderwidth() and
     // setverttablebordercolor(), draw vertical lines on the left and
     // the right side of the table
     if ($this->verttableborderwidth && $this->verttablebordercolor !== false) {
         $this->setcolor($this->verttablebordercolor);
         PDF_setlinewidth($this->pdf, $this->verttableborderwidth);
         PDF_moveto($this->pdf, $this->firstxpos + 0.5 * $this->verttableborderwidth, $this->firstypos);
         PDF_lineto($this->pdf, $this->firstxpos + 0.5 * $this->verttableborderwidth, $this->ypos);
         PDF_stroke($this->pdf);
         PDF_moveto($this->pdf, $this->firstxpos + $this->width - 0.5 * $this->verttableborderwidth, $this->firstypos);
         PDF_lineto($this->pdf, $this->firstxpos + $this->width - 0.5 * $this->verttableborderwidth, $this->ypos);
         PDF_stroke($this->pdf);
     }
     // When scheduled via setcolspacingwidth() and
     // setcolspacingcolor(), draw lines between the
     // columns
     if ($this->colspacingwidth && $this->colspacingcolor !== false) {
         for ($c = 1; $c < sizeof($this->colparam); $c++) {
             $cp =& $this->colparam[$c];
             $borderpos = $cp->xpos - 0.5 * $this->colspacingwidth;
             $this->setcolor($this->colspacingcolor);
             PDF_setlinewidth($this->pdf, $this->colspacingwidth);
             PDF_moveto($this->pdf, $borderpos, $this->firstypos);
             PDF_lineto($this->pdf, $borderpos, $this->ypos);
             PDF_stroke($this->pdf);
         }
     }
     for ($c = 0; $c < sizeof($this->colparam); $c++) {
         $cp =& $this->colparam[$c];
         $cnp =& $cp->normcellparam;
         if ($cp->eotcallbackfn) {
             $fn = $cp->eotcallbackfn;
             $fn($cp->xpos, $cp->xpos + $cnp->leftborderwidth + $cnp->leftpadding, $cp->xpos + $cp->width - ($cnp->rightborderwidth + $cnp->rightpadding), $cp->xpos + $cp->width, $this->ypos);
         }
     }
 }
Esempio n. 5
0
 function Curve($xo, $yo, $x, $y, $px1, $py1, $px2, $py2, $linha = 2.001, $color1 = '#000000', $color2 = '#000000')
 {
     if ($teck2) {
         $this->SetLine($linha);
         $this->SetBoth($color1);
         $this->SetFill($color2);
     }
     PDF_moveto($this->pdf, $xo, $yo);
     PDF_curveto($this->pdf, $px1, $py1, $px2, $py2, $x, $y);
     if ($teck) {
         PDF_stroke($this->pdf);
     }
     if ($this->depurar) {
         echo '<b>PDF:</b> Adicionado uma curva.<br>';
     }
 }
Esempio n. 6
0
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
PDF_setcolor($p, "fill", "rgb", 1.0, 0.8, 0.1);
PDF_moveto($p, 150, 750);
PDF_lineto($p, 450, 750);
PDF_lineto($p, 100, 800);
PDF_curveto($p, 80, 500, 70, 550, 250, 650);
PDF_closepath($p);
PDF_fill_stroke($p);
// Circle
PDF_setcolor($p, "fill", "rgb", 0.8, 0.5, 0.8);
PDF_circle($p, 400, 600, 75);
PDF_fill_stroke($p);
// Funky Arc
PDF_setcolor($p, "fill", "rgb", 0.8, 0.5, 0.5);
PDF_moveto($p, 200, 600);
PDF_arc($p, 300, 600, 50, 0, 120);
PDF_closepath($p);
PDF_fill_stroke($p);
// Dashed rectangle
PDF_setcolor($p, "stroke", "rgb", 0.3, 0.8, 0.3);
PDF_setdash($p, 4, 6);
PDF_rect($p, 50, 500, 500, 300);
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=gra3.pdf");
Esempio n. 7
0
}
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_set_info($mypdf, "Creator", "Online Bus Service");
PDF_set_info($mypdf, "Author", "Mukesh Kumar");
PDF_set_info($mypdf, "Title", "Speedticket");
PDF_set_info($mypdf, "Subject", "Ticket");
PDF_set_info($mypdf, "Keywords", "Bus Ticket");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 12);
PDF_setcolor($mypdf, "stroke", "rgb", 0.5, 0.5, 0.5, 1);
PDF_moveto($mypdf, 50, 810);
PDF_lineto($mypdf, 500, 810);
PDF_stroke($mypdf);
PDF_moveto($mypdf, 50, 100);
PDF_lineto($mypdf, 500, 100);
PDF_stroke($mypdf);
PDF_show_xy($mypdf, "Online Bus Ticket", 200, 800);
PDF_show_xy($mypdf, "Your Ticket Details", 70, 700);
PDF_continue_text($mypdf, "Bus Details");
PDF_continue_text($mypdf, "Bus ID: " . $b[0] . " Bus Name:" . $b[1] . " From: " . $b[2] . " To: " . $b[3]);
PDF_continue_text($mypdf, "Departure: " . $b[4] . " Arrival:" . $b[5] . " Type: " . $b[6] . "Seats:" . $b[7]);
PDF_continue_text($mypdf, " Fare: " . $b[8] . " Facilities: " . $b[9] . " Stars: " . $b[10]);
PDF_continue_text($mypdf, "===================================================================");
PDF_continue_text($mypdf, "Your Details");
PDF_continue_text($mypdf, "Your Name: " . $u[0] . " Email: " . $u[1] . " Mobile: " . $u[2] . " Address: " . $u[3]);
PDF_continue_text($mypdf, "Country: " . $u[4] . " Gender: " . $u[5] . " BusID: " . $u[6] . " Bus Date: " . $u[7]);
PDF_continue_text($mypdf, "Registration Date: " . $u[8] . " Your Seats: " . $u[9] . " Seats: " . $u[10]);
PDF_continue_text($mypdf, "Price: " . $u[11] . " PNR: " . $u[12]);
PDF_continue_text($mypdf, "===================================================================");
Esempio n. 8
0
 function writeLine($sx, $sy, $ex, $ey, $rgb = "000000")
 {
     $this->openPage();
     list($pdf_sx, $pdf_sy) = $this->posTopDown($sx, $sy);
     list($pdf_ex, $pdf_ey) = $this->posTopDown($ex, $ey);
     $this->setColor($rgb);
     PDF_setlinewidth($this->pdf, 1.0);
     PDF_moveto($this->pdf, $pdf_sx, $pdf_sy);
     PDF_lineto($this->pdf, $pdf_ex, $pdf_ey);
     PDF_stroke($this->pdf);
 }