Ejemplo n.º 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);
Ejemplo n.º 2
0
 function image_rx_ry($image, $x, $y, $width, $height, $right, $bottom, $ox, $oy, $scale)
 {
     $tmpname = tempnam(WRITER_TEMPDIR, WRITER_FILE_PREFIX);
     imagepng($image->get_handle(), $tmpname);
     $pim = pdf_open_image_file($this->pdf, "png", $tmpname, "", 0);
     // Fill bottom-right quadrant
     $cy = $y;
     while ($cy + $height > $bottom) {
         $cx = $x;
         while ($cx < $right) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx += $width;
         }
         $cy -= $height;
     }
     // Fill bottom-left quadrant
     $cy = $y;
     while ($cy + $height > $bottom) {
         $cx = $x;
         while ($cx + $width > $x - $ox) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx -= $width;
         }
         $cy -= $height;
     }
     // Fill top-right quadrant
     $cy = $y;
     while ($cy < $y + $oy) {
         $cx = $x;
         while ($cx < $right) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx += $width;
         }
         $cy += $height;
     }
     // Fill top-left quadrant
     $cy = $y;
     while ($cy < $y + $oy) {
         $cx = $x;
         while ($cx + $width > $x - $ox) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx -= $width;
         }
         $cy += $height;
     }
     pdf_close_image($this->pdf, $pim);
     unlink($tmpname);
 }
 pdf_show_xy($pdf, strtoupper($name), $startx + 90, 391);
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 20);
 }
 pdf_show_xy($pdf, 'has demonstrated that they are certifiable ' . 'by passing a rigorous exam', $startx, 340);
 pdf_show_xy($pdf, 'consisting of three multiple choice questions.', $startx, 310);
 pdf_show_xy($pdf, "{$name} obtained a score of {$score}" . '%.', $startx, 260);
 pdf_show_xy($pdf, 'The test was set and overseen by the ', $startx, 210);
 pdf_show_xy($pdf, 'Fictional Institute of PHP Certification', $startx, 180);
 pdf_show_xy($pdf, "on {$date}.", $startx, 150);
 pdf_show_xy($pdf, 'Authorised by:', $startx, 100);
 // add bitmap signature image
 $signature = pdf_load_image($pdf, 'png', '/Program Files/Apache Software Foundation/Apache2.2/htdocs/phpmysql4e/chapter33/signature.png', '');
 pdf_fit_image($pdf, $signature, 200, 75, '');
 pdf_close_image($pdf, $signature);
 // set up colors for ribbon
 pdf_setcolor($pdf, 'fill', 'rgb', 0, 0, 0.4, 0);
 // dark blue
 pdf_setcolor($pdf, 'stroke', 'rgb', 0, 0, 0, 0);
 // black
 // draw ribbon 1
 pdf_moveto($pdf, 630, 150);
 pdf_lineto($pdf, 610, 55);
 pdf_lineto($pdf, 632, 69);
 pdf_lineto($pdf, 646, 49);
 pdf_lineto($pdf, 666, 150);
 pdf_closepath($pdf);
 pdf_fill($pdf);
 // outline ribbon 1
 pdf_moveto($pdf, 630, 150);
Ejemplo n.º 4
0
 /**
  * Overlay image
  *
  * Parameter array:
  * 'x': int X-point of overlayed image
  * 'y': int Y-point of overlayed image
  * 'filename': string The filename of the image to overlay
  * 'width': int [optional] The width of the overlayed image (resizing if possible)
  * 'height': int [optional] The height of the overlayed image (resizing if possible)
  * 'alignment': array [optional] Alignment
  */
 function image($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $filename = $params['filename'];
     $width = isset($params['width']) ? $params['width'] : false;
     $height = isset($params['height']) ? $params['height'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     if (substr($filename, -4) == '.png') {
         $type = 'png';
     } elseif (substr($filename, -4) == '.jpg') {
         $type = 'jpeg';
     }
     $image = pdf_load_image($this->_pdf, $type, realpath($filename), '');
     $width_ = pdf_get_value($this->_pdf, 'imagewidth', $image);
     $height_ = pdf_get_value($this->_pdf, 'imageheight', $image);
     $outputWidth = $width !== false ? $width : $width_;
     $outputHeight = $height !== false ? $height : $height_;
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if ($alignment['horizontal'] == 'right') {
         $x -= $outputWidth;
     } elseif ($alignment['horizontal'] == 'center') {
         $x -= $outputWidth / 2;
     }
     if ($alignment['vertical'] == 'top') {
         $y += $outputHeight;
     } elseif ($alignment['vertical'] == 'center') {
         $y += $outputHeight / 2;
     }
     if ($width === false && $height === false) {
         $scale = 1;
     } else {
         $scale = max($height / $height_, $width / $width_);
     }
     pdf_place_image($this->_pdf, $image, $this->_getX($x), $this->_getY($y), $scale);
     pdf_close_image($this->_pdf, $image);
     parent::image($params);
 }
Ejemplo n.º 5
0
$i_offset = 200;
$str_pdf_name = "invoice.pdf";
$pdf = pdf_new();
pdf_open_file($pdf, "{$str_current_path}/Temp_doc/{$str_pdf_name}");
pdf_set_info($pdf, "Author", "etelegate");
pdf_set_info($pdf, "Title", "Invoice Form");
pdf_set_info($pdf, "Creator", "etelegate");
pdf_set_info($pdf, "Subject", "Invoice");
pdf_begin_page($pdf, 595, 842);
//pdf_add_outline($pdf, "Page 5");
$font = pdf_findfont($pdf, "Verdana", "winansi", 1);
pdf_setfont($pdf, $font, 12);
//pdf_set_value($pdf, "textrendering", 1);
$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/logo2os.jpg");
pdf_place_image($pdf, $jpeg_image, 200, $i_top, 1.0);
pdf_close_image($pdf, $jpeg_image);
/*$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/top1.jpg");
pdf_place_image($pdf, $jpeg_image, 300, $i_top+20, 0.5);
pdf_close_image($pdf, $jpeg_image);
$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/top4.jpg");
pdf_place_image($pdf, $jpeg_image, 301, $i_top-10, 0.5);
pdf_close_image($pdf, $jpeg_image);*/
$i_top -= 50;
pdf_show_xy($pdf, "Company Name", $i_left, $i_top);
pdf_show_xy($pdf, "[Company Name]", $i_left + $i_offset, $i_top);
$i_top -= 30;
pdf_show_xy($pdf, "Address", $i_left, $i_top);
pdf_show_xy($pdf, "[Address]", $i_left + $i_offset, $i_top);
/*if ($str_city != "") {
	$i_top -= 20;
	pdf_show_xy($pdf, $str_city, $i_left+$i_offset, $i_top);