Image not readable or empty!!

1,359 views
Skip to first unread message

amu...@sisfo.com

unread,
Sep 13, 2013, 10:59:34 AM9/13/13
to dom...@googlegroups.com
Image not readable or empty......Alguien puede ayudarme con este error? he intentado todas las soluciones que han comentado y sigue sin funcionar...la ruta de la imagen esta correcta (/dev/cakephp/app/webroot/img/_3cbb15f8.png) pero no la muestra....he intentado con archivos jpg, jpeg, png, gif y ninguno sirve...agradezco la ayuda ya que llevo varios dias buscando en la web y nada me ha funcionado.


BrianS

unread,
Sep 13, 2013, 3:24:55 PM9/13/13
to dom...@googlegroups.com
I don't know enough Spanish to answer you natively, so hopefully this suffices ...

You're using CakePHP. How are you loading the HTML into dompdf? Can we see some of your code? The path looks to be absolute from the file system, which should work so long as you are calling $dompdf->load_html() and the image path is correct. You should also make sure dompdf has read/write access to the temporary directory specified by DOMPDF_TEMP_DIR.
Message has been deleted

amu...@sisfo.com

unread,
Sep 13, 2013, 5:38:29 PM9/13/13
to dom...@googlegroups.com
Thanks BrianS,

I dont speak english well, but I show you something about source code.

default.ctp
<?php 
    require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
    //App::import('Vendor', 'dompdf/dompdf_config.inc.php');
    $dompdf = new DOMPDF();
    $dompdf->load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
    $dompdf->render();
    //$dompdf->stream('mypdf.pdf',array('Attachment' => '1')); //Para descargar PDF
    echo $dompdf->output();
?>

dompdf_config.inc.php
def("DOMPDF_TEMP_DIR", sys_get_temp_dir());
def("DOMPDF_ENABLE_REMOTE", false);

BrianS

unread,
Sep 13, 2013, 6:38:42 PM9/13/13
to dom...@googlegroups.com
No worries, I'm sure your English is better than my Spanish!

Are you using v0.5.x or v0.6.x of dompdf? Looks like you're using v0.6.x (which we recommend). If so you no longer need to use utf8_decode() on your content, and this is something we recommend not doing since it can alter the content of your document.

So the absolute file system path to your image is /dev/cakephp...? Remove configuration shouldn't come into play. DOMPDF_TEMP_DIR is set to sys_get_temp_dir() so I would make sure your web server has read/write access to that directory. A configuration summary is included with v0.6.x and can be found at dompdf/www/setup.php, but you'll need to access it through your web server since it produces an HTML document.

You could also change DOMPDF_TEMP_DIR to your CakePHP temp directory since the web server should have write access there for caching.

amu...@sisfo.com

unread,
Sep 16, 2013, 9:53:05 AM9/16/13
to dom...@googlegroups.com
Hi BrianS...

Im using dompdf_0-6-0_beta3, i delete utf8_decode() in file default.ctp, and i changed sys_get_temp_dir() to the directory where I save de images (dev/cakephp/app/webroot/img), but the image does not appear :(.

I found a temporary solution...into the file where Im generating the pdf file I wrote the next line and the image appear into the pdf file: <img src="/var/www/dev/cakephp/app/webroot/img/<?php echo $post['Post']['filename']?>" />

Thanks!

amu...@sisfo.com

unread,
Sep 16, 2013, 9:54:09 AM9/16/13
to dom...@googlegroups.com
Hi BrianS...

Im using dompdf_0-6-0_beta3, i delete utf8_decode() in file default.ctp, and i changed sys_get_temp_dir() to the directory where I save de images (dev/cakephp/app/webroot/img), but the image does not appear :(.

I found a temporary solution...into the file where Im generating the pdf file I wrote the next line and the image appear into the pdf file: <img src="/var/www/dev/cakephp/app/webroot/img/<?php echo $post['Post']['filename']?>" />

Thanks!

El viernes, 13 de septiembre de 2013 09:59:34 UTC-5, amu...@sisfo.com escribió:

BrianS

unread,
Sep 17, 2013, 10:13:47 AM9/17/13
to dom...@googlegroups.com
This makes sense. When you load your HTML using $dompdf->load_html() paths are based on the local file system. So if you use an absolute image reference you have to do it from the root of the file system, not the root of your web site. Relative links will be based on the location of the running PHP script.

Andres Añez

unread,
Feb 21, 2015, 9:02:12 PM2/21/15
to dom...@googlegroups.com, amu...@sisfo.com
Reply all
Reply to author
Forward
0 new messages