How do I position text in TCPDF using the XY coord

2019-07-15 12:04发布

问题:

I'd like to position text so that if the font size changes, the baseline of the text will stay the same.

When I use

$pdf->SetXY($x,$y);
$pdf->Write(0, "Hello"......);

This sets the position of the text at its top left.

Note: I am using write to render the text.

回答1:

I used the following syntax and am able to chose the absolute position to start the table.

$pdf->SetFont('verdana', 'B', 18);
$pdf->SetXY(15, 20);

$output = <<<EOD
<table cellspacing="0" cellpadding="1" border="0">
.....
$pdf->writeHTML($output, true, false, false, false, '');


回答2:

According to Example #57 and its showcase you have the option to use

$pdf->Cell(30, 0, 'Bottom-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'B', 'B');


标签: php tcpdf