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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:29:07  来源:igfitidea点击:

How do I position text in TCPDF using the XY coordinates of the bottom left of the text?

phptcpdf

提问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 writeto 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

根据实例#57它的展示你可以选择使用

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