コード例 #1
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
$im = pdf_open_jpeg($p, "php-big.jpg");
pdf_place_image($p, $im, 200, 700, 1.0);
PDF_save($p);
// Save current coordinate system settings
$nx = 50 / PDF_get_value($p, "imagewidth", $im);
$ny = 100 / PDF_get_value($p, "imageheight", $im);
PDF_scale($p, $nx, $ny);
pdf_place_image($p, $im, 200 / $nx, 600 / $ny, 1.0);
PDF_restore($p);
// Restore previous
pdf_close_image($p, $im);
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);
コード例 #2
0
 /**
  * Put a cell onto the PDF document
  *
  * Puts a cell onto the PDF document including cell border,
  * cell padding and the actual cell data.
  *
  * @param    float              $xpos        The left starting position
  * @param    float              $ypos        The top starting position
  * @param    float              $width       The width of the cell
  * @param    float              $height      The height of the cell
  * @param    object cellparam   $cellparam   Object describing the cell
  *                                           parameters
  *
  * @access   private
  */
 function drawcell($xpos, $ypos, $width, $height, $cellparam, $putdata)
 {
     // When scheduled via $cellparam->bgcolor, fill up the cell with
     // a background color
     if ($cellparam->bgcolor !== false) {
         $this->setcolor($cellparam->bgcolor);
         PDF_setlinewidth($this->pdf, 1);
         PDF_rect($this->pdf, $xpos + 0.5, $this->ypos - $height + 0.5, $width - 1, $height - 1);
         PDF_closepath_fill_stroke($this->pdf);
     }
     $horilinexpos1 = $xpos;
     $horilinexpos2 = $xpos + $width;
     // When scheduled via $cellparam->topborder{width,color},
     // draw a horizontal line on the top of the cell
     if ($cellparam->topborderwidth > 0 && $cellparam->topbordercolor !== false) {
         $borderypos = $ypos - 0.5 * $cellparam->topborderwidth;
         $this->setcolor($cellparam->topbordercolor);
         PDF_setlinewidth($this->pdf, $cellparam->topborderwidth);
         PDF_moveto($this->pdf, $horilinexpos1, $borderypos);
         PDF_lineto($this->pdf, $horilinexpos2, $borderypos);
         PDF_stroke($this->pdf);
     }
     // When scheduled via $cellparam->bottomborder{width,color},
     // draw a horizontal line on the bottom of the cell
     if ($cellparam->bottomborderwidth > 0 && $cellparam->bottombordercolor !== false) {
         $borderypos = $ypos - $height + 0.5 * $cellparam->bottomborderwidth;
         $this->setcolor($cellparam->bottombordercolor);
         PDF_setlinewidth($this->pdf, $cellparam->bottomborderwidth);
         PDF_moveto($this->pdf, $horilinexpos1, $borderypos);
         PDF_lineto($this->pdf, $horilinexpos2, $borderypos);
         PDF_stroke($this->pdf);
     }
     $vertlineypos1 = $this->ypos;
     $vertlineypos2 = $this->ypos - $height;
     // When scheduled via $cellparam->leftborder{width,color},
     // draw a vertical line on the left side of the cell
     if ($cellparam->leftborderwidth > 0 && $cellparam->leftbordercolor !== false) {
         $borderxpos = $xpos + 0.5 * $cellparam->leftborderwidth;
         $this->setcolor($cellparam->leftbordercolor);
         PDF_setlinewidth($this->pdf, $cellparam->leftborderwidth);
         PDF_moveto($this->pdf, $borderxpos, $vertlineypos1);
         PDF_lineto($this->pdf, $borderxpos, $vertlineypos2);
         PDF_stroke($this->pdf);
     }
     // When scheduled via $cellparam->rightborder{width,color},
     // draw a vertical line on the right side of the cell
     if ($cellparam->rightborderwidth > 0 && $cellparam->rightbordercolor !== false) {
         $borderxpos = $xpos + $width - 0.5 * $cellparam->rightborderwidth;
         $this->setcolor($cellparam->rightbordercolor);
         PDF_setlinewidth($this->pdf, $cellparam->rightborderwidth);
         PDF_moveto($this->pdf, $borderxpos, $vertlineypos1);
         PDF_lineto($this->pdf, $borderxpos, $vertlineypos2);
         PDF_stroke($this->pdf);
     }
     // Output the cell data
     if ($putdata) {
         $dataxpos = $xpos + $cellparam->leftborderwidth + $cellparam->leftpadding;
         $dataypos = $ypos - $cellparam->toppadding - $cellparam->topborderwidth;
         if ($this->cliptocell) {
             $datawidth = $width - ($cellparam->leftborderwidth + $cellparam->leftpadding + $cellparam->rightborderwidth + $cellparam->rightpadding);
             $dataheight = $height - ($cellparam->topborderwidth + $cellparam->toppadding + $cellparam->bottomborderwidth + $cellparam->bottompadding);
             PDF_save($this->pdf);
             PDF_rect($this->pdf, $dataxpos, $dataypos - $dataheight, $datawidth, $dataheight);
             PDF_clip($this->pdf);
         }
         $cellparam->jhpci_class->jhpci_putdata($dataxpos, $dataypos);
         if ($this->cliptocell) {
             PDF_restore($this->pdf);
         }
     }
 }