Esempio n. 1
1
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_set_info($p, "Creator", "coords.php");
PDF_set_info($p, "Author", "Rasmus Lerdorf");
PDF_set_info($p, "Title", "Coordinate Test (PHP)");
PDF_begin_page($p, 595, 842);
PDF_translate($p, 0, 842);
// Move Origin
PDF_scale($p, 1, -1);
// Reflect across horizontal axis
PDF_set_value($p, "horizscaling", -100);
// Mirror
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, -38.0);
PDF_show_xy($p, "Top Left", 10, 40);
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);
Esempio n. 2
0
PDF_begin_page($p, 595, 842);
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
PDF_set_parameter($p, "overline", "true");
PDF_show_xy($p, "Overlined Text", 50, 780);
PDF_set_parameter($p, "overline", "false");
PDF_set_parameter($p, "underline", "true");
PDF_continue_text($p, "Underlined Text");
PDF_set_parameter($p, "strikeout", "true");
PDF_continue_text($p, "Underlined strikeout Text");
PDF_set_parameter($p, "underline", "false");
PDF_set_parameter($p, "strikeout", "false");
PDF_setcolor($p, "fill", "rgb", 1.0, 0.1, 0.1);
PDF_continue_text($p, "Red Text");
PDF_setcolor($p, "fill", "rgb", 0, 0, 0);
PDF_set_value($p, "textrendering", 1);
PDF_setcolor($p, "stroke", "rgb", 0, 0.5, 0);
PDF_continue_text($p, "Green Outlined Text");
PDF_set_value($p, "textrendering", 2);
PDF_setcolor($p, "fill", "rgb", 0, 0.2, 0.8);
PDF_setlinewidth($p, 2);
PDF_continue_text($p, "Green Outlined Blue Text");
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=coords.pdf");
echo $buf;
PDF_delete($p);
 /**
  * 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 = "";
 }