Nghi Vo
Nghi Vo

Reputation: 155

xhtml2pdf does not show image always

I use xhmtl2pd tool to convert html to pdf. Here is a piece of my html

<tr>
    <td style="width:10px;vertical-align:top">&bull; </td>
    <td style="padding:0 0 5px 0;width:200px;display:inline-block">
        blah blah <br/>              
        <img src="images/little-gray-arrow.png" height="10" width="11" alt="blah" /> 
    </td>
</tr>

The bizarre thing is if I remove the br tag then the image of little-gray-arrow.png never shows up. Put the br tag back, the image shows up in the "next" line. I have tried with all options, padding, margin, and none works.

I also try to inline-displaying an image between text, and the image clock.png bottom half always get cut off, regardless what I tried.

<tr>
    <td style="width:10px;vertical-align:top">&bull; </td>
    <td style="padding:0 0 5px 0;width:200px;">
        Wait
        <img src="images/clock.png" height="20" width="20" alt="20" />
        minutes
    </td>
</tr>

Does anyone know how to solve this problem and it is just the way xhmtl2pdf is. Can the xhtml2pdf display image inline?

Thanks

Upvotes: 3

Views: 3698

Answers (2)

Sourav Purkait
Sourav Purkait

Reputation: 344

Dont use absolute paths in url or src. Use fullpath like https://abcd.com/.../image.png . It worked for me

Upvotes: 4

Lukasz Koziara
Lukasz Koziara

Reputation: 4320

If you need render image format like GIF or PNG, you should install PIL library. The Python Imaging Library (PIL) is requred by ReportLab for handling PNG/GIF image.

Refer: Output image to pdf with xhtml2pdf

Upvotes: 0

Related Questions