Ejemplo n.º 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 float $x x position
  * @param float $y y position
  * @param int $w width (in pixels)
  * @param int $h height (in pixels)
  * @param string $resolution
  *
  * @return void
  * @internal param string $img_type the type (e.g. extension) of the image
  */
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $img_type = Cache::detect_type($img_url);
     if (!$img_type) {
         return;
     }
     $func = "imagecreatefrom{$img_type}";
     if (!function_exists($func_name)) {
         if (!method_exists("Dompdf\\Helpers", $func_name)) {
             throw new Exception("Function {$func_name}() not found.  Cannot convert {$type} image: {$image_url}.  Please install the image PHP extension.");
         }
         $func_name = "\\Dompdf\\Helpers::" . $func_name;
     }
     $src = @call_user_func($func_name, $image_url);
     if (!$src) {
         return;
         // Probably should add to $_dompdf_errors or whatever here
     }
     // Scale by the AA factor and DPI
     $x = $this->_upscale($x);
     $y = $this->_upscale($y);
     $w = $this->_upscale($w);
     $h = $this->_upscale($h);
     $img_w = imagesx($src);
     $img_h = imagesy($src);
     imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
 }
Ejemplo n.º 2
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 float $x x position
  * @param float $y y position
  * @param int $w width (in pixels)
  * @param int $h height (in pixels)
  * @param string $resolution
  *
  * @return void
  * @internal param string $img_type the type (e.g. extension) of the image
  */
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $img_type = Cache::detect_type($img_url);
     if (!$img_type) {
         return;
     }
     $func = "imagecreatefrom{$img_type}";
     $src = @$func($img_url);
     if (!$src) {
         return;
         // Probably should add to $_dompdf_errors or whatever here
     }
     // Scale by the AA factor and DPI
     $x = $this->_upscale($x);
     $y = $this->_upscale($y);
     $w = $this->_upscale($w);
     $h = $this->_upscale($h);
     $img_w = imagesx($src);
     $img_h = imagesy($src);
     imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
 }
Ejemplo n.º 3
0
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $w = (int) $w;
     $h = (int) $h;
     $img_type = Cache::detect_type($img_url);
     if (!isset($this->_imgs[$img_url])) {
         $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
     }
     $img = $this->_imgs[$img_url];
     $y = $this->y($y) - $h;
     $this->_pdf->fit_image($img, $x, $y, 'boxsize={' . "{$w} {$h}" . '} fitmethod=entire');
 }
Ejemplo n.º 4
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 float $x x position
  * @param float $y y position
  * @param int $w width (in pixels)
  * @param int $h height (in pixels)
  * @param string $resolution
  *
  * @return void
  * @internal param string $img_type the type (e.g. extension) of the image
  */
 function image($img_url, $x, $y, $w, $h, $resolution = "normal")
 {
     $img_type = Cache::detect_type($img_url);
     $img_ext = 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);
 }