October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
page breaks

How to Add Manual Page Breaks in TCPDF (and Keep HTML Within the Footer)

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To start a new TCPDF section on a fresh page, call $pdf->AddPage(); immediately before writing that section:

$pdf->AddPage();
$pdf->writeHTML($nextSection, true, false, true, false, '');

Keep automatic page breaks enabled as well. AddPage() creates a deliberate boundary; setAutoPageBreak(true, PDF_MARGIN_BOTTOM) lets TCPDF flow paragraphs, tables and images onto additional pages without entering the footer area.

Manual versus automatic page breaks

TCPDF has two separate mechanisms, and reliable layouts usually use both.

Manual break: AddPage()

AddPage() is an explicit instruction in your PHP code. Everything written after the call starts on the new page. Put it before the first output belonging to the next logical section:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
  • 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$pdf->AddPage();
$pdf->writeHTML($nextSectionHtml, true, false, true, false, '');

If you call AddPage() after writing part of the section, only the remaining content moves; content already written stays on the previous page.

Automatic flow: setAutoPageBreak()

Automatic breaks are renderer-driven. TCPDF starts a new page when the current position reaches the usable bottom boundary:

$pdf->setAutoPageBreak(true, PDF_MARGIN_BOTTOM);

The second argument is the reserved bottom margin. Set it to the space your footer needs, rather than disabling automatic breaks to force a manual boundary.

Configure a document before writing content

A predictable sequence is: construct the document, set margins and footer space, enable automatic breaks, select a font, add the first page, then write content.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
require_once __DIR__ . '/tcpdf/tcpdf.php';

$pdf = new TCPDF(
    PDF_PAGE_ORIENTATION,
    PDF_UNIT,
    PDF_PAGE_FORMAT,
    true,
    'UTF-8',
    false
);

$pdf->setCreator('My application');
$pdf->setAuthor('My application');
$pdf->setTitle('Manual section breaks');
$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->setFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setAutoPageBreak(true, PDF_MARGIN_BOTTOM);
$pdf->setFont('dejavusans', '', 10);

$pdf->AddPage();
$pdf->writeHTML('<h1>Introduction</h1><p>First section.</p>', true, false, true, false, '');

// The next section begins on a fresh page.
$pdf->AddPage();
$pdf->writeHTML('<h1>Next section</h1><p>This starts on a new page.</p>', true, false, true, false, '');

$pdf->Output('manual-breaks.pdf', 'I');

The constructor’s orientation and format become the defaults. Margins and footer settings determine the usable content rectangle; automatic flow respects those settings.

Rank #2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
  • HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
  • Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
  • HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
  • All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
  • Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality

Use AddPage() when a section must start on a new page

Use a manual break for discrete units such as a cover followed by a report, a chapter boundary, or an appendix. The method accepts optional orientation, format, margin and table-of-contents arguments:

$pdf->AddPage(
    $_orientation = '',
    $_format = '',
    $_keepmargins = false,
    $_tocpage = false
);

For example, a landscape table can begin on a landscape page and then return to the document’s normal orientation:

$pdf->AddPage('L', 'A4');
$pdf->writeHTML($wideTableHtml, true, false, true, false, '');

$pdf->AddPage('P', 'A4');
$pdf->writeHTML($narrativeHtml, true, false, true, false, '');

Use the optional arguments only when that page genuinely needs a different layout. If you need to preserve custom margins or integrate a table-of-contents page, pass the corresponding options deliberately and test the result with your headers and footer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep long HTML from running into the footer

A manual break does not make later content fit on one page. A long paragraph, image or table can still need several pages. Leave automatic breaks enabled and reserve the footer area:

$pdf->setFooterMargin(18);
$pdf->setAutoPageBreak(true, 24);

Choose the bottom value so it covers the footer plus any visual clearance below body content. If the value is too small, text can overlap the footer; if it is too large, usable page space is unnecessarily reduced.

Rank #3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
  • 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

Headers and footers

Header and footer callbacks run as pages are created. When you change orientation or format with AddPage(), verify that your callback calculations use the current page dimensions. A footer that is positioned manually outside TCPDF’s normal footer area can still overlap body content even when automatic breaks are correctly configured.

Writing HTML that can span pages

For legacy TCPDF code, the common call is:

$pdf->writeHTML(
    $html,
    true,   // reset height
    false,  // cell stretch
    true,   // allow page break
    false,  // reset x
    ''      // alignment
);

The positioned form gives cell-level control:

$pdf->writeHTMLCell(
    0, 0, '', '', $html,
    0, 1, 0, true, '', true
);

These methods can flow content when automatic page breaks are enabled, but complex HTML/CSS behavior depends on the TCPDF release. The current TCPDF HTML/CSS guide specifically recommends addHTMLCell() for content that may cross a page boundary because it accounts for automatic page and region breaks and appends the block to each page it reaches.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
// Current tc-lib-pdf HTML/CSS engine
$pdf->addHTMLCell($htmlBlock);

If your project is using the legacy TCPDF API, continue with writeHTML() or writeHTMLCell() and keep automatic breaks on. Do not assume a CSS declaration alone behaves identically across legacy releases and the current HTML/CSS engine.

A complete two-section example

This example combines a deliberate chapter boundary with flowing content inside each chapter:

<?php
require_once __DIR__ . '/tcpdf/tcpdf.php';

$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->setMargins(20, 25, 20);
$pdf->setHeaderMargin(10);
$pdf->setFooterMargin(15);
$pdf->setAutoPageBreak(true, 25);
$pdf->setFont('dejavusans', '', 10);

$pdf->AddPage();
$intro = '<h1>Project report</h1>'
       . '<p>Introductory text goes here. A long body can flow naturally ' 
       . 'onto another page.</p>';
$pdf->writeHTML($intro, true, false, true, false, '');

// Explicit boundary: chapter 2 starts on a new page.
$pdf->AddPage();
$chapter = '<h1>Chapter 2</h1>'
         . '<p>This chapter begins at the top of a fresh page.</p>'
         . '<table border="1" cellpadding="4">'
         . '<tr><th>Item</th><th>Status</th></tr>'
         . '<tr><td>Example</td><td>Complete</td></tr>'
         . '</table>';
$pdf->writeHTML($chapter, true, false, true, false, '');

$pdf->Output('report.pdf', 'I');

There is no need to predict how many lines fit on a page. TCPDF handles the natural flow, while the one explicit AddPage() controls the chapter boundary.

Rank #4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
  • 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

When CSS page-break rules are appropriate

The current feature index documents paged-media controls, including orphan and widow handling and page-break control, as well as the print media type. Those controls belong to the current HTML/CSS engine. Legacy writeHTML() support can differ by release, so test CSS rules against the exact TCPDF version deployed by your application.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use CSS for renderer-level rules such as keeping a heading with the following paragraph, and use AddPage() for a business-level boundary that must occur at a known point in your program. Do not replace a known API boundary with CSS unless you have verified the target engine.

Troubleshooting manual page breaks

The section does not start on a new page

  • Confirm that AddPage() appears before the first writeHTML(), writeHTMLCell() or other output for that section.
  • Check that no output is sent between your intended boundary and the call.
  • Make sure you are calling the TCPDF object that is actually used for the final Output().

Text overlaps the footer

  • Enable automatic flow with setAutoPageBreak(true, $bottomMargin).
  • Increase the bottom margin to include the complete footer and a safety gap.
  • Check manually positioned cells and images; an object placed with absolute coordinates can bypass normal flow.

A table or HTML block is cut off

  • Keep the automatic-break argument enabled in writeHTML().
  • For the current HTML/CSS engine, use addHTMLCell() for blocks that may span pages.
  • Reduce oversized images or split a deliberately indivisible component into smaller blocks.

The next page has the wrong orientation or margins

  • Pass the required orientation and format to AddPage().
  • If custom margins are involved, use the keep-margins option as required by your layout and verify the header/footer callbacks on that page.

Blank pages appear

  • Look for two consecutive AddPage() calls, including one hidden in a helper method.
  • Do not add a page after a renderer has already created one automatically unless a blank separator is intentional.
  • Log the page number before each manual break while diagnosing the generation path.

Performance, reliability and testing

Manual breaks are inexpensive; the expensive work is usually HTML parsing, image loading and rendering. Avoid repeatedly writing tiny fragments when one coherent block will do, but split very large, independently managed sections so a failure can be isolated.

  • Test the shortest and longest realistic versions of every section.
  • Include tables with many rows, images near the bottom margin and content containing non-ASCII characters.
  • Render portrait and landscape pages separately when you use mixed orientation.
  • Inspect the first page after a break, the last page before a break and every footer for overlap.
  • Keep the TCPDF version consistent between development and production; HTML/CSS behavior is version-sensitive.

For deterministic output, set the same margins, font and footer settings before every generation. A page break is only as reliable as the layout state surrounding it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual goal is capturing a web page as an image or PDF rather than generating a document with TCPDF, ScreenshotNeo provides a single HTTP request. Its API accepts a URL and returns PNG, JPEG, WebP or PDF; it can accept consent banners before capture and remove more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the ScreenshotNeo API documentation for all options. A cURL request is:

Best Value
Sale
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
  • 8 ream case (4,000 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
const data = Buffer.from(await res.arrayBuffer());

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Features include full-page lazy-image loading, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper sizes and page ranges, custom CSS and JavaScript, clicks before capture, selector hiding, selector/delay/network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work.

All features are included on every plan: Free provides 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to start with the monthly free allowance.

Frequently Asked Questions

Can I call AddPage() before the first page?

Yes, but the usual sequence is to configure the document, call AddPage() once for the first page, then write its content. Calling it again creates the next page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I turn off automatic breaks after adding a manual break?

No. Keep automatic breaks enabled so long content written after the deliberate boundary can continue onto additional pages.

What should I use for a long HTML block in current TCPDF?

The current HTML/CSS guide recommends addHTMLCell() for content that may span a page boundary. Legacy applications commonly use writeHTML() or writeHTMLCell() with automatic breaks enabled.

Quick Recap

Bestseller No. 1
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use; Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$6.97
Bestseller No. 2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
$6.97
Bestseller No. 3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$23.99
Bestseller No. 4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$29.14
SaleBestseller No. 5
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$49.99

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.