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
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.
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With