我正努力在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');
Run Code Online (Sandbox Code Playgroud)
我肯定得到一个输出,但我期待第一个和第二个writeHTMLCell()在它们之间重置空间.
http://www.tcpdf.org/doc/classTCPDF.html#ab3bbdb7c85ea08d175fd559be6132ba0
文档说第二个参数是上边距.
简而言之,如果有必要,我想弄清每一行的边距.但我可能正在使用错误的方法.我上面的例子似乎完全忽略了这个参数.但它似乎没有左右参数的问题.
TCPDF SetMargins方法是:
SetMargins($left,$top,$right = -1,$keepmargins = false)
Run Code Online (Sandbox Code Playgroud)
所以你可以在AddPage();下面的方法之前使用它:
$pdf->SetMargins(10, 20, 10, true);
$pdf->AddPage();
//your HTML code here ...
Run Code Online (Sandbox Code Playgroud)
$keepmargins(boolean) 如果为true则覆盖默认页边距.
| 归档时间: |
|
| 查看次数: |
38453 次 |
| 最近记录: |