DOMPDF images not showing on new server

2019-07-31 07:52发布

问题:

I've created an application which outputs a PDF report based on an HTML page using DOMPDF.

This works fine on my test server, but when I've migrated it over to the live server, none of the images show in the PDF. It's not showing a RED X - just nothing there at all.

I've checked that the new server meets the requirements using the config tool, and I've enabled the "leave images in temp" debugging option, and nothing is being created in the the temp directory.

Any ideas what might have changed to stop it from working?

回答1:

It appears that if your CSS specifies your images as display:block, DOMPDF won't show them sometimes. Have changed my code so that it uses a pdf-specific CSS file without that it.

No idea why it worked on the other server though....



回答2:

Note: For windows servers I had to point the true path to the images:

<img src="C:\path\to\image\folder\image.jpg">


回答3:

I had this problem too. On the local server i could use for the image

<img src="www.test.dev/img/test.jpg" /> ,

but on the live server i had to change it to

<img src="img/test.jpg" />.

In this way you force dompdf on the server to locally access the image file.



标签: php pdf dompdf