1
votes

I have problem with TCPDF and SVG images.

I need view image in cell as table (for example 3 cols and many rows).

Images in generated PDF are on new line and not abreast.

My Code:

public function addImage($fileName){
    $this->x=$this->_pdfObject->getX();
    $this->y=$this->_pdfObject->getY();

    $this->_pdfObject->setXY($this->x, $this->y);

    $this->_pdfObject->MultiCell(0, 0, '<img src="'.$fileName.'">', 0, 'L', 0, 1, '', '', true, null, true);

}

Can you help me, please? Thanks.

1

1 Answers

0
votes

Every time you write in Cell to the PDF file you can let the engine know where should the new cell be written (or where you want the pointer to go). The attribute $ln in Cell() and MultiCell() is controlling this. There are three possible values for this:

0 - leave the pointer after the written cell
1 - move to new line and to the left side of page (or right in RTL documents)
2 - move the pointer below

In Cell() function the default value is 0, in MultiCell() the default is 1.

So to write more than one mulitcell in one line you should use:

$this->_pdfObject->MultiCell(0, 0, '<img src="'.$fileName.'">', 0, 'L', 0, 0, '', '', true, null, true);

Note that 0 is used as the 7th parameter.

Once you write different cells on one line you can use Ln() to move the pointer to the new line and to the left (or right in RTL mode).