TCPDF Page Borders?

I am trying to achieve a simple 1px solid red border around every page generated in TCPDF. Previously, using other PDF scripts, I had to draw a rectangle after doing rough calculations to get the width and height of the page and -20px (to allow 10px indentation on each side). However, I am not sure how to achieve a similar result with TCPDF.

Does anyone have any experience?

+4
source share
4 answers

Here you go (this will draw a black line of 15 dots 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()); 
+5
source

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

+1
source

Use Rect :

 $pdf->SetLineStyle( array( 'width' => 15, 'color' => array(0,0,0))); $pdf->Rect(0, 0, $pdf->getPageWidth(), $pdf->getPageHeight()); 
+1
source
 $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()); 
0
source

Source: https://habr.com/ru/post/1339168/


All Articles