コード例 #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);
         }
     }
 }
コード例 #3
0
PDF_show_xy($pdf, $total, 250, $y - 320);
PDF_show_xy($pdf, $doubleline, 250, $y - 330);
PDF_show_xy($pdf, $descript, 30, $y - 400);
//PRINT AMOUNT ----------------------------------------------------------
$amt_x = 470;
$amt_y = 655;
PDF_show_xy($pdf, '$ ' . $debit_card, $amt_x, $amt_y - 30);
PDF_show_xy($pdf, '$ ' . $amex_card, $amt_x, $amt_y - 60);
PDF_show_xy($pdf, '$ ' . $visa_card, $amt_x, $amt_y - 90);
PDF_show_xy($pdf, '$ ' . $total_staff_salary, $amt_x, $amt_y - 120);
PDF_show_xy($pdf, '$ ' . $phone_bill, $amt_x, $amt_y - 150);
PDF_show_xy($pdf, '$ ' . $rent_bill, $amt_x, $amt_y - 180);
PDF_show_xy($pdf, '$ ' . $electricity_bill, $amt_x, $amt_y - 210);
PDF_show_xy($pdf, '$ ' . $director_fee, $amt_x, $amt_y - 240);
PDF_show_xy($pdf, '$ ' . $consignment_payment, $amt_x, $amt_y - 270);
PDF_show_xy($pdf, '$ ' . $total_amount, $amt_x, $amt_y - 320);
PDF_show_xy($pdf, strtoupper($desc), 150, $amt_y - 400);
PDF_close_image($pdf, $images);
//test
/*end page*/
PDF_end_page($pdf);
/*close and save file*/
PDF_close($pdf);
$buf = PDF_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=gen01.pdf");
print $buf;
PDF_save($pdf);
コード例 #4
0
<?php

$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 500);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: {$mylen}");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;
PDF_save($mypdf);