TCPDF page borders?

北战南征 提交于 2019-12-10 17:13:03

问题


I'm trying to achieve simple 1px solid red border around each page generated in TCPDF. Previously using other PDF scripts I was forced to draw a rectangle after doing some rough calculations with getting the page width and height and -20px (to allow for 10px indentation on each side). However I'm unsure how I can achieve a similar result with TCPDF.

Does anyone have any experience?


回答1:


Here you go (this will draw a black line of 15 points around the current page)

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->AddPage();

$pdf->SetLineStyle( array( 'width' => 15, 'color' => array(0,0,0)));

$pdf->Line(0,0,$pdf->getPageWidth(),0); 
$pdf->Line($pdf->getPageWidth(),0,$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,$pdf->getPageHeight(),$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,0,0,$pdf->getPageHeight());



回答2:


You can use the TCPDF Line function and create four lines around each side of the page.




回答3:


Use Rect:

$pdf->SetLineStyle( array( 'width' => 15, 'color' => array(0,0,0)));
$pdf->Rect(0, 0, $pdf->getPageWidth(), $pdf->getPageHeight());



回答4:


$pdf->SetLineStyle( array( 'width' => 15, 'color' => array(0,0,0)));
$pdf->Line(0,0,$pdf->getPageWidth(),0); 
$pdf->Line($pdf->getPageWidth(),0,$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,$pdf->getPageHeight(),$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,0,0,$pdf->getPageHeight());
$pdf->SetLineStyle( array( 'width' => 14, 'color' => array(255,255,255)));
$pdf->Line(0,0,$pdf->getPageWidth(),0); 
$pdf->Line($pdf->getPageWidth(),0,$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,$pdf->getPageHeight(),$pdf->getPageWidth(),$pdf->getPageHeight());
$pdf->Line(0,0,0,$pdf->getPageHeight());


来源:https://stackoverflow.com/questions/4955917/tcpdf-page-borders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!