0

I have an HTML file that shows images correctly. However, the PDF generated from this HTML file does not show those images. What am I missing?

My Python code to generate PDF from HTML.

options = {
        'page-size' : 'A4',
        'dpi' : 400
    }
css = ['../css/report.css', '../css/w3.css']
pdfkit.from_file(htmlFilePath, pdfFilePath, options=options, css=css)

The HTML file (used to generate PDF) has reference to image files as shown here:

<h2 class="heading">Trends of parameters and set-points</h2>
<h3>Trend-1</h3>
<div>
    <img src="../png/PT-1.png"></img>
</div>
<h3>Trend-2</h3>
<div>
    <img src="../png/PT-2.png"></img>
</div>
<h3>Trend-3</h3>
<div>
    <img src="../png/PT-3.png"></img>
</div>
xerx593
  • 12,237
  • 5
  • 33
  • 64
cogitoergosum
  • 2,309
  • 4
  • 38
  • 62
  • 1
    check [this](https://stackoverflow.com/questions/16627310/wkhtmltopdf-not-loading-local-css-and-images)(, bro) (...pdfkit is a "wkhtmltopdf"-"wrapper") – xerx593 Apr 11 '18 at 20:26
  • 1
    Using `src` attribute pointing to complete URI (as shown here - https://stackoverflow.com/a/31905972/919480) helped. Thanks! – cogitoergosum Apr 12 '18 at 03:09

0 Answers0