Beispiel #1
0
 /**
  * Add an image to the pdf.
  *
  * The image is placed at the specified x and y coordinates with the
  * given width and height.
  *
  * @param string $img_url the path to the image
  * @param string $img_type the type (e.g. extension) of the image
  * @param float $x x position
  * @param float $y y position
  * @param int $w width (in pixels)
  * @param int $h height (in pixels)
  */
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $img_type = Image_Cache::detect_type($img_url);
     $img_ext = Image_Cache::type_to_ext($img_type);
     if (!$img_ext) {
         return;
     }
     $func = "imagecreatefrom{$img_ext}";
     $src = @$func($img_url);
     if (!$src) {
         return;
         // Probably should add to $_dompdf_errors or whatever here
     }
     // Scale by the AA factor
     $x *= $this->_aa_factor;
     $y *= $this->_aa_factor;
     $w *= $this->_aa_factor;
     $h *= $this->_aa_factor;
     $img_w = imagesx($src);
     $img_h = imagesy($src);
     imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
 }
Beispiel #2
0
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $w = (int) $w;
     $h = (int) $h;
     $img_type = Image_Cache::detect_type($img_url);
     $img_ext = Image_Cache::type_to_ext($img_type);
     if (isset($this->_imgs[$img_url])) {
         $img = $this->_imgs[$img_url];
     } else {
         $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
     }
     $y = $this->y($y) - $h;
     $this->_pdf->fit_image($img, $x, $y, "boxsize=\\{{$w} {$h}\\} fitmethod=entire");
 }
  function image($img_url, $x, $y, $w, $h, $resolution = "normal") {
    $w = (int)$w;
    $h = (int)$h;

    $img_type = Image_Cache::detect_type($img_url);
    $img_ext  = Image_Cache::type_to_ext($img_type);

    if ( !isset($this->_imgs[$img_url]) ) {
      $this->_imgs[$img_url] = $this->_pdf->load_image($img_ext, $img_url, "");
    }

    $img = $this->_imgs[$img_url];

    $y = $this->y($y) - $h;
    $this->_pdf->fit_image($img, $x, $y, 'boxsize={'."$w $h".'} fitmethod=entire');
  }
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $img_type = Image_Cache::detect_type($img_url);
     $img_ext = Image_Cache::type_to_ext($img_type);
     if (!$img_ext) {
         return;
     }
     $func = "imagecreatefrom{$img_ext}";
     $src = @$func($img_url);
     if (!$src) {
         return;
     }
     $x *= $this->_aa_factor;
     $y *= $this->_aa_factor;
     $w *= $this->_aa_factor;
     $h *= $this->_aa_factor;
     $img_w = imagesx($src);
     $img_h = imagesy($src);
     imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
 }