php 如何使用文本左下角的 XY 坐标在 TCPDF 中定位文本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35506228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I position text in TCPDF using the XY coordinates of the bottom left of the text?
提问by Rob
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.
注意:我write
用来渲染文本。
回答by Nishanth Rajan
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, '');
回答by Pmpr
According to Example #57and its showcaseyou have the option to use
$pdf->Cell(30, 0, 'Bottom-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'B', 'B');