title: TCPDF - adding a background to a table cell or div that shows on PDF
body: <p>I am using TCPDF to create PDF files on the fly on my website.</p>
  
  <p>This is all working well, and so I would be reluctant to change and use something else now.</p>
  
  <p>But my problem I have just now is that I need to include an image in the PDF file, which will be of unknown size, dimensions, aspect ratio, etc.</p>
  
  <p>My solution for adding this was going to be to add it as a background to a table cell or to a div, and use the 'cover' property to add the image.</p>
  
  <p>This works fine in HTML and looks the way I want it to.</p>
  
  <p>But adding it to the PDF file results in a blank cell or blank div, and no background is added.</p>
  
  <p>I have tried both of the following methods:</p>
  
  <pre><code>$html .= "&lt;div align=\"center\"&gt;\n";
  $html .= "&lt;table cellpadding=\"0\" cellspacing=\"0\" style=\"width:200px; height:200px; border:2px solid black;\"&gt;\n";
  $html .= "&lt;tr&gt;&lt;td style=\"width:200px; height:200px; background: url(model.jpg) 50% 0 no-repeat; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;\"&gt;&lt;/td&gt;&lt;/tr&gt;\n";
  $html .= "&lt;/table&gt;\n";
  $html .= "&lt;/div&gt;\n";
  
  $html .= "&lt;div align=\"center\"&gt;\n";
  $html .= "&lt;div style=\"width:200px; height:200px; border:2px solid black; background: url(model.jpg) 50% 0 no-repeat; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;\"&gt;&lt;/div&gt;\n";
  $html .= "&lt;/div&gt;\n";
  </code></pre>
  
  <p>Both of these show up the solid border, but no background.</p>
  
  <p>There is one example on the TCPDF site about adding backgrounds, but it adds a background that covers the whole page, which is not what I want.</p>
  
  <p>Can anyone help me get these background images showing up on the created PDF, or suggest an alternative way I can add an image to the document that needs to be a fixed size on the page, but where the source image is of unknown dimensions and aspect ratio?</p>