How to place a table or image dynamically to pdf in PHP

I’ve a pdf file of a rule that need to pass a several approval. In the end of the file (content), I need to:

  1. Add a QR Code as an e-sign in the specific place, or
  2. Add a border-less table that include some text and a QR Code after the last content of the pdf. Which mean if the last content of pdf ends in the height(x) of 200, then the content should placed in (as an example) the height(x) of 210.

Example

Is that possible?

TCPDF writeHtml will place the generated html in the top of the page, while writeHTMLCell and MultiCell will need a specific x and y to be defined.

I’m also trying in MPDF, but it stuck like the TCPDF.

The code before writing the html looks like this,

$pageCount = PDF::setSourceFile($file);
$template = PDF::importPage($i);
$size = PDF::getTemplateSize($template);
PDF::AddPage($size['orientation'], array($size['width'], $size['height']));
PDF::useTemplate($template);

// After this, I need to call writeHtml, writeHTMLCell, or MultiCell, but none of those met what I need.
// Or placing an image with PDF::Image also need to define the x and y
...
// PDF::SetX()
// PDF::SetY()
// PDF::Image($qrPath, null, null, 12, 12, 'PNG');
// PDF::WriteHTML(view('document-requests.approver.stamp', ['qr' => $qrPath]), true, false, true, false, '');
PDF::Output($file, 'F');