TCPDF删除空格/底部边距

时间:2017-03-12 12:52:42

标签: php margin tcpdf

我已经阅读了大约5篇关于此的帖子并尝试了代码修复而没有任何快乐,所以我发布了自己的内容,希望这不会冒犯。

我正在尝试创建一个包含2列的页面,并且正在使用MultiCell() - 我对此感到满意并成功删除了顶部/右侧的边距&左

enter image description here

从图像中可以看出,页面底部有一个空格,可以将文本框的底部推到下一页。

有人可以帮助我,我已经尝试了好几个小时了!这是我的代码:

// create new PDF document
$pageLayout = array( 139 , 76 );
$pdf = new TCPDF('l', 'mm', $pageLayout, true, 'UTF-8', false, true);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('Online Ticket Seller Ticket');
$pdf->setPrintFooter(false);
$pdf->setPrintHeader(false);
$pdf->SetMargins(PDF_MARGIN_LEFT-15, PDF_MARGIN_TOP-29, PDF_MARGIN_RIGHT-16);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('helvetica', '', 10, '', true);
// add a page
$pdf->AddPage();
$pdf->SetFillColor(255, 255, 255);

$pdf->setCellPaddings(1, 1, 1, 1);
$pdf->setCellMargins(0, 0, 0, 0);

// set some text for example
$txt1 = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, 

sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 
incididunt ut labore et dolore magna aliqua.';
$txt2 = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';

// Multicell test
$pdf->MultiCell(38, 75, '[LEFT] '.$txt1, 1, 'L', 0, 0, '', '', true);
$pdf->MultiCell(101, 75, '[RIGHT] '.$txt2, 1, 'L', 0, 0, '', '', true);

//Close and output PDF document
$pdf->Output('example_005.pdf', 'I');

非常感谢提前。

我读过的页面(没有解决我的问题):

1 个答案:

答案 0 :(得分:1)

注意:

以下答案太大而不能作为评论但不足以成为真正的答案,它更倾向于查询问题中给出的一些信息。

另请注意(来自我的评论)

  

您能告诉我们您已阅读并尝试了哪些问题以及哪些问题尚未解决您的问题,否则我们只会链接/建议您已经尝试过但未通过的问题。干杯

您的问题是Here's my code

  

$ pdf-> SetMargins(PDF_MARGIN_LEFT-15,PDF_MARGIN_TOP-29,PDF_MARGIN_RIGHT-16);

这是非常错误的,您想要设置值:

$pdf->SetMargins(15, 29, 16);

在句法上更正确。

您还可以尝试使用 the documentation 中的值$keepmargins

  

参数
      $ left(float)左边距。
      $ top(浮动)上边距。
      $ right(浮动)右边距。默认值是左边的       $ keepmargins(boolean)if true覆盖默认页边距

所以:

 $pdf->SetMargins(15, 29, 16,true);