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

If Playwright’s page.pdf() file contains only the first page, the browser usually printed a layout that hides, clips, or constrains the rest of the document. Playwright renders PDFs with print CSS by default. Inspect print rules, wait for the application to finish rendering, set page geometry and margins explicitly, and remove fixed-height or overflow constraints. If the screen layout is the intended output, call await page.emulateMedia({ media: 'screen' }) before creating the PDF.

Why page.pdf() can produce one page

Playwright’s documentation states that page.pdf() “generates a pdf of the page with print css media.” That means the PDF is not necessarily a copy of what you see in a normal browser tab. Every @media print rule participates in layout, and print-specific rules can hide sections, collapse containers, or change positioning.

A one-page PDF is therefore usually a pagination or layout problem rather than a PDF-writing limit. Common causes include:

  • A print rule applies display: none or visibility: hidden to later content.
  • A wrapper has a fixed height or max-height.
  • overflow: hidden or overflow: auto clips content outside the wrapper.
  • Absolute positioning removes content from normal document flow.
  • The application has not finished rendering fonts, images, or client-side sections when the PDF is generated.
  • Your CSS @page size, API format, and margins disagree.

Use a reliable PDF baseline

Start with an explicit navigation wait, font wait, paper format, margins, and background setting. The following JavaScript pattern is a good minimal reproduction and production baseline:

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
await page.goto(url, { waitUntil: 'networkidle' });
await page.evaluate(() => document.fonts?.ready);

// Use screen CSS only if that is the intended design:
// await page.emulateMedia({ media: 'screen' });

const pdf = await page.pdf({
  path: 'output.pdf',
  format: 'A4',
  printBackground: true,
  preferCSSPageSize: true,
  margin: {
    top: '12mm',
    right: '12mm',
    bottom: '12mm',
    left: '12mm'
  }
});

format: 'A4' selects a paper size of 8.27 by 11.7 inches. Letter is 8.5 by 11 inches. You can instead provide unit-labeled width and height. Margins default to zero, so specifying all four while debugging makes the printable area predictable.

Choose print or screen media deliberately

Keep the default print media when the site has a proper print stylesheet. If the screen design is the desired document and print CSS hides or rearranges required sections, switch media before calling page.pdf():

await page.emulateMedia({ media: 'screen' });
const pdf = await page.pdf({
  path: 'screen-layout.pdf',
  format: 'A4',
  printBackground: true,
  margin: { top: '12mm', right: '12mm', bottom: '12mm', left: '12mm' }
});

This does not repair a genuinely broken layout; it tells the page to use screen media rules while Chromium creates the PDF. Check that your screen layout itself can flow across finite pages.

Inspect print CSS and the document tree

Search every stylesheet, component, and generated style tag for print-specific declarations. In particular, look for @media print, display: none, visibility: hidden, fixed heights, max-height, overflow clipping, and print-only wrappers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

For a diagnostic run, inspect the computed style of the document’s main containers in print media:

const layout = await page.evaluate(() => {
  const selectors = ['html', 'body', '.document', '.content'];
  return selectors.map(selector => {
    const el = document.querySelector(selector);
    if (!el) return { selector, missing: true };
    const style = getComputedStyle(el);
    return {
      selector,
      clientHeight: el.clientHeight,
      scrollHeight: el.scrollHeight,
      height: style.height,
      maxHeight: style.maxHeight,
      overflow: style.overflow,
      display: style.display,
      visibility: style.visibility,
      position: style.position
    };
  });
});
console.log(layout);

A large scrollHeight with a small fixed clientHeight is a strong indication that a wrapper is clipping content. Remove or override the constraint in print styles rather than increasing the PDF page height indefinitely.

Remove print-time clipping and preserve flow

Use normal document flow for content that must paginate. This print stylesheet removes common clipping rules and makes page breaks explicit:

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  .document,
  .content {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .new-page {
    break-before: page;
    page-break-before: always;
  }
}

Use break-before, break-after, and break-inside for modern CSS paged-media control. The older page-break-before, page-break-after, and page-break-inside properties remain useful for compatibility. break-inside: avoid asks the browser to keep a block together, but an element taller than a page must still split.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Check positioned elements

Large sections placed with position: absolute or position: fixed do not contribute to normal flow in the same way as ordinary blocks. A later section can overlap them or appear outside the expected page area. Temporarily switch major content containers to position: static in print CSS and regenerate the file. If that fixes pagination, replace absolute layout with flow, grid, or flex rules for the printable version.

Make CSS page size and API size agree

If your stylesheet contains @page { size: ... }, set preferCSSPageSize: true when you want that CSS size to take precedence. The documented default is false; with the default, the API’s format, width, or height can win instead.

Choose one intentional source of truth:

Goal Recommended settings
Use CSS paper and margins @page plus preferCSSPageSize: true; still set PDF margins while diagnosing.
Use Playwright geometry Set format or explicit width/height, and omit conflicting CSS size rules.
Match a physical standard Use format: 'A4' or format: 'Letter' with explicit four-sided margins.

A Playwright issue opened on January 15, 2025 against version 1.49.1 reported unexpected margins when @page was present and CSS page size was not preferred. Treat margin behavior as version- and option-dependent: record the Playwright, browser, operating-system, and language versions in a minimal reproduction, then compare preferCSSPageSize: true with explicit margin values.

Wait for the content that controls layout

waitUntil: 'networkidle' waits for a quiet network, but it does not guarantee that your application has completed every render step. Wait for a reliable application selector, fonts, and layout-critical images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('#report-ready');
await page.evaluate(() => document.fonts?.ready);
await page.waitForFunction(() => {
  return [...document.images].every(img => img.complete);
});

Prefer an application-owned readiness marker such as #report-ready over an arbitrary sleep. If a chart, editor, or image loads after that marker, expose a more precise selector or readiness promise. Validate the wait against your application; no universal timing threshold guarantees stable pagination.

Debug in a minimal reproduction

  1. Save the exact HTML, CSS, data, and assets that produce the one-page file.
  2. Log the Playwright package, browser revision, operating system, Node or other language runtime, and launch options.
  3. Generate one PDF with default print media and one after emulateMedia({ media: 'screen' }).
  4. Remove application styles in batches until the missing pages return; the last batch identifies the problematic rule.
  5. Compare API geometry with and without preferCSSPageSize.
  6. Open the PDF in more than one viewer and inspect the HTML directly to distinguish a viewer issue from a clipped render.

Common symptoms and fixes

Symptom Likely cause Fix
Only the first section appears Later sections are hidden by print CSS. Remove print-time display: none/visibility: hidden or use screen media intentionally.
Content is cut at a container edge Fixed height, max-height, or overflow clipping. Set height: auto, max-height: none, and overflow: visible for print.
Break rules seem ignored Break is applied to the wrong element, or a parent is clipped/positioned. Apply breaks to flow elements and remove parent constraints.
Blank or incomplete charts Rendering continues after navigation. Wait for a readiness selector, fonts, images, and chart completion.
Unexpected whitespace or margins @page and API geometry conflict. Choose a single size source, enable preferCSSPageSize when appropriate, and set all margins explicitly.
Different page count after an upgrade Browser or Playwright pagination behavior changed. Pin versions for diagnosis, capture environment details, and retest the minimal reproduction.

Performance, reliability, and cost considerations

Waiting for network idle, fonts, images, and application readiness improves correctness but can increase latency. Keep a targeted readiness contract instead of waiting for every optional request. Block or defer nonessential analytics and live widgets in the printable route, but do not block assets that determine dimensions. Generate PDFs with a stable browser version in CI and compare page count, file size, and representative page images when changing CSS.

For very long documents, avoid forcing one enormous fixed-height page. Let the page box paginate naturally and use section-level break rules. If a page must be exactly one physical sheet, that is a separate requirement from producing a complete multi-page document.

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

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a rendered capture without maintaining Playwright launch code. A single request can return PNG, JPEG, WebP, or PDF. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled.

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

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Best Value
HP Printer Paper | 8.5 x 11 Paper | Office 20 lb | 3 Ream Case - 1500 Sheets | 92 Bright | Made in USA - FSC Certified | 112090C, White
  • Made in USA: HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America.
  • Optimized for HP technology: All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment.
  • Perfect everyday office paper: Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office. Perfect for everyday black and white printing.
  • Certified sustainable: HP Office20 20lb printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design).
  • ColorLok technology printing paper: ColorLok technology provides more vivid colors, bolder blacks and faster drying.

For a PDF or image endpoint call, see the ScreenshotNeo documentation. This cURL example requests a WebP capture:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -o shot.webp

The same request in Python:

import requests

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

And in 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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));

ScreenshotNeo includes full-page capture with lazy images loaded, element selection by CSS selector, dark mode, 12 device presets and custom viewports, retina scale, PDF paper settings and page ranges, HTML/CSS rendering, custom JavaScript, clicks, selector waits, delays, network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.

Every feature is included on every plan: 1,000 shots per month free with no card, Starter $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing provides two months free. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

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

FAQ

Does page.pdf() have a one-page limit?

No. It paginates according to the rendered print layout and finite paper size. A one-page result usually indicates hidden or clipped content, incomplete rendering, or conflicting geometry.

Should I always use emulateMedia(‘screen’)?

No. Use it only when the screen stylesheet is the intended output. A correctly designed print stylesheet is usually preferable for invoices, reports, and formal documents.

Will page-break-after: always force a new PDF page?

It requests a break when the element participates in normal flow. Fixed, clipped, or absolutely positioned parents can prevent the expected result.

Why does changing margins alter the page count?

Margins reduce the printable page box. Less available height can move content to additional pages, while conflicting @page and API settings can produce surprising geometry.

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

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
$34.85

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.