Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesTo reserve space at the bottom of a TCPDF page when content flows onto new pages, pass the margin as the second argument to setAutoPageBreak(): $pdf->setAutoPageBreak(true, $bottomMargin);. For example, $pdf->setAutoPageBreak(true, 15); reserves 15 document user units above the bottom edge for the automatic page break.
Set the automatic page-break margin
Call setAutoPageBreak() during document setup, before writing page content. Its first argument turns automatic page breaking on or off; its second argument sets the bottom margin. The margin is measured in the user units configured for the PDF, so the number you pass must match your document’s units.
<?php
require_once __DIR__ . '/tcpdf.php';
$pdf = new TCPDF();
$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->setHeaderMargin(PDF_MARGIN_HEADER);
$pdf->setFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setAutoPageBreak(true, PDF_MARGIN_BOTTOM);
$pdf->AddPage();
$pdf->Write(0, 'Content flows to a new page before entering the bottom margin.');
$pdf->Output('example.pdf', 'I');
This follows the setup pattern in TCPDF’s official example_006.php. Replace PDF_MARGIN_BOTTOM with a numeric value or your own constant if you need a different amount of reserved space. The official API reference describes the margin argument in user units.
Understand which margin each method controls
setMargins() sets the left, top, and right content margins; it does not have a bottom-margin parameter. The automatic page-break margin is configured separately. Header, footer, and cell spacing are separate concerns as well.
#1 Best Overall
| Setting | What it controls |
|---|---|
setMargins($left, $top, $right) |
Left, top, and right page margins. |
setAutoPageBreak(true, $bottomMargin) |
Automatic page-break behavior and the bottom space to reserve. |
setHeaderMargin($margin) |
Header spacing. |
setFooterMargin($margin) |
Footer spacing. |
If text or a table appears to have excess whitespace inside its cells, inspect the cell padding or cell margins instead of changing the page-break margin. Those settings affect content inside cells, not where TCPDF triggers an automatic page break.
Choose whether page breaks should be automatic
Enable automatic page breaks and supply a bottom margin when TCPDF should move flowing content to a new page while leaving a reserved area at the bottom. Disable automatic page breaks when your application needs to decide exactly when and where pages break.
Rank #2
| Configuration | Use it when | Trade-off |
|---|---|---|
$pdf->setAutoPageBreak(true, $bottomMargin); |
Content should flow onto new pages automatically while respecting a bottom margin. | TCPDF handles the page-break trigger; your chosen margin must suit the layout. |
$pdf->setAutoPageBreak(false); |
Your code will place page breaks itself. | You must manage page transitions and prevent content from running into areas you intend to keep clear. |
The API’s margin argument is optional when automatic page breaking is disabled; its documented default is zero. For normal flowing documents, the official setup example uses a separate setAutoPageBreak() call with automatic breaks enabled.
Account for orientation and document units
Use a margin value in the same user units as the PDF. A value such as 15 is not a universal physical measurement: its meaning depends on the units configured for the document. If the reserved space looks unexpectedly large or small, first check those units and the actual value being passed.
TCPDF also exposes setPageOrientation($orientation, $autopagebreak = null, $bottommargin = null), which can accept page-break and bottom-margin settings during an orientation change. For routine setup, the official example configures orientation separately from the explicit setAutoPageBreak() call. If your document changes orientation, confirm that the page-break behavior and margin remain appropriate for the resulting layout.
Troubleshoot a bottom-margin problem
- The margin seems to have no effect: confirm that automatic page breaks are enabled with
trueand that the desired value is the second argument tosetAutoPageBreak(). - You tried to pass a fourth argument to
setMargins(): that method configures left, top, and right margins. Set the bottom page-break margin withsetAutoPageBreak(). - The reserved area is the wrong size: check that the margin value uses the document’s configured user units and is the intended numeric value or constant.
- Only text inside a table cell has unwanted whitespace: adjust the relevant cell padding or cell margin; the page-break bottom margin controls a different part of the layout.
- Content runs into the bottom area after you disabled automatic breaks: with automatic page breaking off, your application is responsible for placing page breaks and keeping content within the intended page area.
- The behavior differs from the example: check the TCPDF version installed in your application. The API documentation, repository example, and source checked on 2026-09-29 describe the current API, but the repository’s
mainbranch can change; verify the signature against your installed version.
Or skip the browser setup
ScreenshotNeo is a separate website screenshot API; it does not set TCPDF margins or generate a TCPDF document. If you also need a website screenshot, one GET request can capture a URL:
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the request options. ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server lets AI agents use screenshot tools, including from Claude, Cursor, or another MCP client. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

