TailTemplate Build stunning websites faster with our pre-designed Tailwind CSS templates

DOMPDF - link to image

dompdf is an HTML to PDF converter. However when working with img tag of DOMPDF, you need to be a bit careful.

Scenario

DOMPDF is made to convert a HTML document to PDF. Theoretically for linking to images, we can use for DOMPDF to show images in PDF file. However if you try to use "url-to-image" for src attribute, it will not work.

Solution

The solution is that you need to change "url-to-image" to absolute path on your server. For example

The end

Hopefully this simple tip helped you with your development. If you like our post, please follow us on Twitter and help spread the word. We need your support to continue. If you have questions or find our mistakes in above tutorial, do leave a comment below to let us know.