示例#1
0
 function Write($msg, $xo, $yo, $x, $y, $fonte = 'normal', $tamanho = '10', $color = '#888888', $align = 'center', $local = 'box')
 {
     $this->SetFont($fonte, $tamanho);
     $this->SetBoth($color);
     switch ($local) {
         case 'xy':
             PDF_show_xy($this->pdf, $msg, $xo, $yo);
             break;
         default:
             // 'box'
             $yo = $this->altura - $yo;
             PDF_show_boxed($this->pdf, $msg, $xo, $yo, $x, $y, $align, '');
     }
     if ($this->depurar) {
         echo "<b>PDF:</b> Adicionado o texto: <pre>{$msg}</pre><br>";
     }
 }
 /**
  * Outputs the the via PDF_show_boxed()
  *
  * Outputs the text via PDF_show_boxed() at the
  * specified coordinates, alignment and leading.
  *
  * @param    float   $xpos        The left starting position
  * @param    float   $ypos        The top starting position
  * @param    string  $alignment   "left"/"right"/"center"
  * @param    float   $leading     The text leading
  *
  * @access   public
  */
 function puttext2($xpos, $ypos, $alignment, $leading)
 {
     if (!$this->layoutvalid) {
         $this->getrequiredlinenum();
     }
     $alignment = strtolower($alignment);
     if ($leading == 0) {
         $leading = $this->fontsize;
     }
     $linenum = sizeof($this->lines);
     $height = $linenum * $leading;
     $font = PDF_findfont($this->pdf, $this->fontface, 'host', 0);
     $descender = -PDF_get_value($this->pdf, "descender", $font) * $this->fontsize;
     //PDF_setcolor($this->pdf, "both", "rgb", 0, 0, 1, 0);
     // The passed x/y-coordinates specify the top left corner of the
     // text area whereas PDF_show_boxed() interpretes the coordinates
     // as the x/y-coordinates of the bottom left corner
     $ypos -= $linenum * $leading;
     // PDF_show_boxed() interpretes the coordinates as the text
     // baseline, but we use it for specifying the geometry of the
     // complete  textblock
     $ypos += $descender;
     // PDF_show_boxed() moves the first text line down by "leading"
     // pixels; we want the first line to really appear at the top of
     // the text block
     $ypos += $leading - $this->fontsize;
     // In order to allow output via PDF_show_boxed(),
     // lines consisting only of single word (i.e. lines
     // not containing a space), are supplemented by a LF
     // character
     for ($i = 0; $i < sizeof($this->lines); $i++) {
         $line =& $this->lines[$i];
         if (strpos($line, " ") === false) {
             $line .= "\n";
         }
     }
     $text = implode(" ", $this->lines);
     $text = ereg_replace("\n +", "\n", $text);
     PDF_setfont($this->pdf, $font, $this->fontsize);
     $this->setcolor($this->fontcolor);
     PDF_set_value($this->pdf, "leading", $leading);
     PDF_show_boxed($this->pdf, $text, $xpos, $ypos - 1, $this->width, (int) ($linenum * $leading) + 1, $alignment, "");
     $this->buffer = "";
 }
示例#3
0
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);