Paweł Forys
Paweł Forys

Reputation: 347

margins in TCPDF when using writeHTML()

I am trying to create a PDF using TCPDF library. I have some problem with table written with method writeHTML() though. When table has to many rows, the rest of it is moved to the next page. Its proper behavior, but I need to to have some top margin on this new page. However TCPDF is making only default margin, which is to small in my case. Ive tried to use setMargins(), setXY() but nothing seems to work. It even looks like general margins of PDF has no influcence on content created by writeHTML(). Anyone had similar problem?

Upvotes: 4

Views: 13820

Answers (2)

Arnab Nandy
Arnab Nandy

Reputation: 6712

TCPDF::SetMargins($left,$top,$right = -1,$keepmargins = false)

And describes the parameters as:

Parameters:

$left   (float) Left margin.
$top    (float) Top margin.
$right  (float) Right margin. Default value is the left one.
$keepmargins    (boolean) if true overwrites the default page margins

So, for the right margin a -1 is used to indicate that no right margin was supplied and to use the same as the left margin. You were using -50 which is not a valid margin.

Try this instead:

$pdf->SetMargins(10, 10, 10, true);

Upvotes: 1

Ian
Ian

Reputation: 755

Try using the PDF_MARGIN_HEADER and PDF_MARGIN_FOOTER variables in the config file of tcpdf. WriteHTML recognises these and skips to the next page and starts taking these margins into account.

Upvotes: 0

Related Questions