Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF - How to adjust height of header?

Tags:

html

php

tcpdf

I am using TCPDF to convert html to pdf format. I am passing a string into the php script to be set as my header. I am having a hard time setting the height of my header. I have tried using SetMargins(PDF_MARGIN_LEFT, 0, PDF_MARGIN_RIGHT) and SetHeaderMargin(0). What it did was to only take off the top margin. I have also alternately looked into adjusting the height of the cell which contains the string within the header.

$this->Cell(0, 0, $newHeaderString, 0, false, 'C', 0, '', 0, false, 'M', 'M');

No luck eliminating white space here either.

I have included an image to show what white space I want to eliminate. The white space is between the header text and the hr tag from the html. Any help would be appreciated!

Link to image

like image 585
ryaa Avatar asked Mar 31 '11 17:03

ryaa


3 Answers

I had the same problem, but solved it by setting the margins with

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

and

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM-15);

so I didn't have to change a defined constant.

like image 152
essesse Avatar answered Oct 16 '22 21:10

essesse


You could define the PDF_MARGIN_TOP constant or you could set the margin explicitly:

$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
like image 26
Seyeong Jeong Avatar answered Oct 16 '22 21:10

Seyeong Jeong


The header itself does not have a height. What you actually want to do is to change the top margin of the main "container". Look in TCPDF config file for:

define ('PDF_MARGIN_TOP', 19);

Changing the value should solve the problem.

like image 7
Vincent Avatar answered Oct 16 '22 20:10

Vincent