Image_Frame_Decorator

Decorates frames for image layout and rendering.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/include/image_frame_decorator.cls.php  
  1. class Image_Frame_Decorator extends Frame_Decorator { 
  2.  
  3. /** 
  4. * The path to the image file (note that remote images are 
  5. * downloaded locally to DOMPDF_TEMP_DIR). 
  6. * @var string 
  7. */ 
  8. protected $_image_url; 
  9.  
  10. /** 
  11. * The image's file error message 
  12. * @var string 
  13. */ 
  14. protected $_image_msg; 
  15.  
  16. /** 
  17. * Class constructor 
  18. * @param Frame $frame the frame to decorate 
  19. * @param DOMPDF $dompdf the document's dompdf object (required to resolve relative & remote urls) 
  20. */ 
  21. function __construct(Frame $frame, DOMPDF $dompdf) { 
  22. parent::__construct($frame, $dompdf); 
  23. $url = $frame->get_node()->getAttribute("src"); 
  24.  
  25. $debug_png = $dompdf->get_option("debug_png"); 
  26. if ($debug_png) print '[__construct '.$url.']'; 
  27.  
  28. list($this->_image_url, /**$type*/, $this->_image_msg) = Image_Cache::resolve_url( 
  29. $url,  
  30. $dompdf->get_protocol(),  
  31. $dompdf->get_host(),  
  32. $dompdf->get_base_path(),  
  33. $dompdf 
  34. ); 
  35.  
  36. if ( Image_Cache::is_broken($this->_image_url) && 
  37. $alt = $frame->get_node()->getAttribute("alt") ) { 
  38. $style = $frame->get_style(); 
  39. $style->width = (4/3)*Font_Metrics::get_text_width($alt, $style->font_family, $style->font_size, $style->word_spacing); 
  40. $style->height = Font_Metrics::get_font_height($style->font_family, $style->font_size); 
  41.  
  42. /** 
  43. * Return the image's url 
  44. * @return string The url of this image 
  45. */ 
  46. function get_image_url() { 
  47. return $this->_image_url; 
  48.  
  49. /** 
  50. * Return the image's error message 
  51. * @return string The image's error message 
  52. */ 
  53. function get_image_msg() { 
  54. return $this->_image_msg; 
  55.