Hi,

not tested, but according to the library, dompdf works in a chroot so it will not consider files outside of his path, this is defined here:

/**
 * ==== IMPORTANT ====
 *
 * dompdf's "chroot": Prevents dompdf from accessing
 * system files or other files on the webserver.
 * All local files opened by dompdf must be in a subdirectory
 * of this directory.
 * DO NOT set it to '/' since this could allow an attacker
 * to use dompdf to read any files on the server. This
 * should be an absolute path.
 * This is only checked on command line call by dompdf.php,
 * but not by direct class use like:
 * $dompdf = new DOMPDF();
 * $dompdf->load_html($htmldata);
 * $dompdf->render();
 * $pdfdata = $dompdf->output();
 */
def("DOMPDF_CHROOT", realpath(DOMPDF_DIR));

To solve you can move the images to the dompdf root, or to the temp directory, which is defined here:

def("DOMPDF_TEMP_DIR", sys_get_temp_dir());

You can edit the dompdf_config.custom.inc.php file and set your own temp directory, just uncomment the following line:

//define("DOMPDF_TEMP_DIR", "/tmp");

And set an absolute path, for example:

define("DOMPDF_TEMP_DIR", $_SERVER["DOCUMENT_ROOT"]."/images/");

Another solution is to set DOMPDF_ENABLE_REMOTE to TRUE, by default is not active:

def("DOMPDF_ENABLE_REMOTE", false);

With this enabled you can use remote files, so you just need to use absolute links to define the image resource, in practice:

<img src="http://www.mywebsite.tld/images/photo001.jpg" />

Instead of simply:

<img src="/images/photo001.jpg" />

If you still do not solve the problem, share your code and your dompdf configuration.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.