I'm creating PDF files with PHP using TCPDF. I have a small problem with created PDF files. I would like to set up right and left margin of each PDF file created. Currently if there is 10px margin on the left side, there is 20px margin on the right side.
How do I set up right and left page margin?
Thank you all for your time and concern.
I tried following;
$pdf->SetMargins(10, 10, -50, true);
and $pdf->SetRightMargin(-50);
without any luck.
In the new documentation it shows the function as
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);
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