简体   繁体   中英

TCPDF Page Margin Issue

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM