/**
  * Put a row onto the PDF document
  *
  * Puts a row onto the PDF document. If there is not enough
  * space left on the page, the function set through
  * setnewpagefunction() is called.
  *
  * @param    array   $dataarray   An array containing one element for
  *                                each column
  *
  * @access   public
  */
 function addrow($dataarray)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     if (sizeof($this->rowbuffer) > 0) {
         $rowbuffer = $this->rowbuffer;
         $this->rowbuffer = array();
         $this->addrow($rowbuffer);
     }
     if ($this->forcedrowheight === false) {
         $maxheight = 0;
     } else {
         $maxheight = $this->forcedrowheight;
     }
     for ($c = 0; $c < sizeof($this->colparam); $c++) {
         $cp =& $this->colparam[$c];
         $cnp =& $cp->normcellparam;
         if (!isset($dataarray[$c])) {
             continue;
         }
         $cnp->jhpci_class->jhpci_setwidth($cp->width - ($cnp->leftborderwidth + $cnp->leftpadding + $cnp->rightborderwidth + $cnp->rightpadding));
         $cnp->jhpci_class->jhpci_setdata($dataarray[$c], 0);
         if ($this->forcedrowheight === false) {
             $height = $cnp->jhpci_class->jhpci_getrequiredheight();
             $height += $cnp->toppadding + $cnp->topborderwidth + $cnp->bottompadding + $cnp->bottomborderwidth;
             if ($height > $maxheight) {
                 $maxheight = $height;
             }
         }
     }
     // Check if there is enough space left on the page
     $requiredspace = $maxheight + $this->bottomborderwidth;
     // Do we have to output the header?
     if ($this->linecount == 0) {
         $requiredspace += $this->topborderwidth;
         if ($this->hasheader) {
             $requiredspace += $this->headerheight + $this->afterheaderborderwidth;
         }
     } else {
         $requiredspace += $this->rowspacingwidth;
     }
     if ($this->ypos - $requiredspace < $this->lastypos) {
         $this->newpage();
     }
     // If this is the first row of the table on this page,
     // we first output the top border and the header
     if ($this->linecount == 0) {
         $this->firstypos = $this->ypos;
         if ($this->topborderwidth > 0) {
             if ($this->topbordercolor !== false) {
                 PDF_setlinecap($this->pdf, 0);
                 PDF_setlinewidth($this->pdf, $this->topborderwidth);
                 $this->setcolor($this->topbordercolor);
                 PDF_moveto($this->pdf, $this->firstxpos, $this->ypos - 0.5 * $this->topborderwidth);
                 PDF_lineto($this->pdf, $this->firstxpos + $this->width, $this->ypos - 0.5 * $this->topborderwidth);
                 PDF_stroke($this->pdf);
             }
             $this->ypos -= $this->topborderwidth;
         }
         if ($this->hasheader) {
             $this->putheader();
         }
     }
     if ($this->linecount > 0 && $this->rowspacingwidth > 0) {
         if ($this->rowspacingcolor !== false) {
             PDF_setlinecap($this->pdf, 0);
             PDF_setlinewidth($this->pdf, $this->rowspacingwidth);
             $this->setcolor($this->rowspacingcolor);
             PDF_moveto($this->pdf, $this->firstxpos, $this->ypos - 0.5 * $this->rowspacingwidth);
             PDF_lineto($this->pdf, $this->firstxpos + $this->width, $this->ypos - 0.5 * $this->rowspacingwidth);
             PDF_stroke($this->pdf);
         }
         $this->ypos -= $this->rowspacingwidth;
     }
     // Alternating background color set through $this->bgcolors
     if ($this->bgcolors !== false) {
         $bgcolorinf = each($this->bgcolors);
         if ($bgcolorinf === false) {
             reset($this->bgcolors);
             $bgcolorinf = each($this->bgcolors);
         }
         $bgcolor = $bgcolorinf['value'];
         if ($bgcolor !== false) {
             $this->setcolor($bgcolor);
             PDF_setlinewidth($this->pdf, 1);
             PDF_rect($this->pdf, $this->firstxpos + 0.5, $this->ypos - $maxheight + 0.5, $this->width - 1, $maxheight - 1);
             PDF_closepath_fill_stroke($this->pdf);
         }
     }
     for ($c = 0; $c < sizeof($this->colparam); $c++) {
         $cp =& $this->colparam[$c];
         if (isset($dataarray[$c])) {
             $putdata = true;
         } else {
             $putdata = false;
         }
         $this->drawcell($cp->xpos, $this->ypos, $cp->width, $maxheight, $cp->normcellparam, $putdata);
     }
     $this->ypos -= $maxheight;
     $this->linecount++;
 }
 function Shape($tipo, $x, $y, $largura = 0, $altura = 0, $linha = 0.001, $color = "#000000", $color2 = "#FFFFFF")
 {
     $this->SetLine($linha);
     $this->SetBoth($color);
     $this->SetFill($color2);
     switch ($tipo) {
         case 'ret':
             PDF_rect($this->pdf, $x, $y, $largura, $altura);
             break;
         case 'elipse':
             PDF_circle($this->pdf, $x, $y, $largura);
             break;
     }
     PDF_fill_stroke($this->pdf);
     if ($this->depurar) {
         echo '<b>PDF:</b> Adicionado um shape.<br>';
     }
 }
PDF_begin_page($p, 595, 842);
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
$text = <<<FOO
This is an example of some text inside a text box in a PDF document.
FOO;
PDF_show_boxed($p, $text, 50, 630, 300, 200, "left");
PDF_rect($p, 50, 630, 300, 200);
PDF_stroke($p);
PDF_show_boxed($p, $text, 50, 420, 300, 200, "right");
PDF_rect($p, 50, 420, 300, 200);
PDF_stroke($p);
PDF_show_boxed($p, $text, 50, 210, 300, 200, "justify");
PDF_rect($p, 50, 210, 300, 200);
PDF_stroke($p);
PDF_show_boxed($p, $text, 50, 0, 300, 200, "fulljustify");
PDF_rect($p, 50, 0, 300, 200);
PDF_stroke($p);
PDF_show_boxed($p, $text, 375, 250, 200, 300, "center");
PDF_rect($p, 375, 250, 200, 300);
PDF_stroke($p);
PDF_end_page($p);
PDF_set_parameter($p, "openaction", "fitpage");
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=coords.pdf");
echo $buf;
PDF_delete($p);
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");
echo $buf;
PDF_delete($p);
Exemple #5
0
 function writeFrameRect($x, $y, $width, $height, $rgb, $frgb)
 {
     $this->openPage();
     list($pdf_x, $pdf_y) = $this->posTopDown($x, $y);
     $this->setColor($frgb);
     PDF_rect($this->pdf, $pdf_x, $pdf_y, $width, -$height);
     PDF_fill($this->pdf);
     $this->setColor($rgb);
     PDF_rect($this->pdf, $pdf_x + 1, $pdf_y - 1, $width - 2, -$height + 2);
     PDF_fill($this->pdf);
 }