Page borders in all pages Using TCPDF

You can add borders to all pages in pdf generated using TCPDF by simple two steps.

  • Create a new class extend from TCPDF class
  • Override the Header method. (Header method is called on generation of each new page in TCPDF)
class PTCPDF extends TCPDF {
protected $processId =0;
protected $header ='';
protected $footer ='';
static $errorMsg ='';
* This method is used to override the parent class method. **/
public function Header()
{ $this->writeHTMLCell($w='', $h='', $x='', $y='', $this->header, $border=0, $ln=0, $fill=0, $reseth=true, $align='L', $autopadding=true);
$this->SetLineStyle( array('width'=>0.40,'color'=> array(0,0,0))); $this->Line(5,5, $this->getPageWidth()-5,5); $this->Line($this->getPageWidth()-5,5, $this->getPageWidth()-5, $this->getPageHeight()-5); $this->Line(5, $this->getPageHeight()-5, $this->getPageWidth()-5, $this->getPageHeight()-5); $this->Line(5,5,5, $this->getPageHeight()-5);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s