title: TCPDF: How can I place an image into an HTML block?
body: <p>I've been working with TCPDF for a few months now; off and on. It's worked fairly well for most of my HTML templates, but I've always had problems placing images into the PDF's. The images are usually placed into the body, not the header. My placement is either a fixed position from the top-left corner or it is relative to the bottom of the document. In either case, I've had issues. When the text changes in the HTML, I have to reposition the image. Multiple column tables can make things even more difficult. Note: "class pdf extends TCPDF".</p>
  
  <pre><code>$this-&gt;pdf-&gt;AddPage();
  $this-&gt;pdf-&gt;writeHTML($pdf_html);
  $cur_page = $this-&gt;pdf-&gt;getPage();
  $x_pos = $this-&gt;pdf-&gt;GetX();
  $y_pos = $this-&gt;pdf-&gt;GetY();
  // Place image relative to end of HTML
  $this-&gt;pdf-&gt;SetXY($x_pos, $y_pos - 54);
  $this-&gt;pdf-&gt;Image('myimage.png');
  </code></pre>
  
  <p>Does anyone know a fool-proof way of placing an Image into a PDF that is generated from HTML. I thought about splitting the HTML into two parts, but I'm not sure if it would work well either.</p>