gpt4 book ai didi

TCPDF SetMargins 方法

转载 作者:行者123 更新时间:2023-12-01 08:41:53 25 4
gpt4 key购买 nike

我正在努力在 tcpdf 中获得准确的定位。我试图在多个地方使用 SetMargins(),但我一定误解了这种方法的用法。
它似乎没有像我预期的那样工作。

$pdf->SetFont('helvetica', '', 12);
$pdf->AddPage();
$pdf->SetMargins(10, 10, 10, true); // set the margins

$html = 'Here is some text';

$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'L', true);

$pdf->SetMargins(0, 10, 0, true); // put space of 10 on top

$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'C', true);
$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'R', true);

$pdf->Output('example_002.pdf', 'I');

我肯定会得到一个输出,但我希望第一个和第二个 writeHTMLCell() 能够重置它们之间的空间。

http://www.tcpdf.org/doc/classTCPDF.html#ab3bbdb7c85ea08d175fd559be6132ba0

文档说第二个参数用于上边距。

简而言之,如有必要,我想弄乱每行的边距。但我可能为此使用了错误的方法。
我上面的示例似乎完全忽略了该参数。但是左右参数好像没有问题。

最佳答案

TCPDF SetMargins方法是:

SetMargins($left,$top,$right = -1,$keepmargins = false)

所以你可以在 AddPage();之前使用它方法如下:
$pdf->SetMargins(10, 20, 10, true);
$pdf->AddPage();
//your HTML code here ...
$keepmargins(boolean)如果 true 覆盖默认页边距。

关于TCPDF SetMargins 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8810440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com