Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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 Now×
Skip to content
Chromium

How to Change Page Orientation for Selected Puppeteer PDF Pages

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.

Short answer: Puppeteer’s page.pdf({ landscape: true }) sets landscape orientation for the generated document as a whole; it does not accept a list of page numbers to rotate. For content-driven layouts, try CSS @page rules with named pages, force the relevant section onto its own page, and set preferCSSPageSize: true. Test the output with the exact Chromium build you deploy. If you need particular final PDF page numbers to have dependable dimensions, render sections separately and merge the PDFs in order.

What “selected pages” means in a Puppeteer PDF

There are two different requirements that are easy to confuse:

  • Selected content: a known section, such as a wide table, should use landscape layout while the surrounding report stays portrait.
  • Selected output page numbers: after pagination, pages 3 and 7 of the finished PDF must be landscape.

CSS paged-media rules are a natural starting point for the first case because you can assign a page style to identifiable content. They are not a dependable page-number orientation map. Page numbers can change when text, fonts, margins, or paper size change, and support for advanced page selectors depends on the actual renderer.

For the second case, a robust pipeline is to render portrait and landscape sections separately with their respective settings, then merge the PDF pages in the required order. Validate page order and dimensions after merging. Puppeteer’s pageRanges option controls which pages are included; it does not assign a different orientation to each selected page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Use CSS named pages for a known wide section

Give the wide content its own named page style and force it to start and end on page boundaries. This is suitable when you know which content needs more horizontal room, rather than needing to target a final page number.

1. Mark the content in HTML

For example, put the wide table in a dedicated block:

<section class="wide-section">
  <h2>Quarterly results</h2>
  <table>
    <!-- wide table content -->
  </table>
</section>

Keep ordinary report content outside that section so it can use the default page style. If the section is longer than one page, the browser may use multiple pages with the named style; inspect the rendered PDF to confirm the result.

2. Define the page boxes in print CSS

@page {
  size: A4 portrait;
  margin: 15mm;
}

@page wide {
  size: A4 landscape;
  margin: 12mm;
}

.wide-section {
  page: wide;
  break-before: page;
  break-after: page;
}

The first rule establishes the default portrait page size and margins. The named wide page rule sets landscape dimensions and its own margins. The page property assigns the marked section to that named style, while the break rules isolate it from adjacent content. Adjust margins to suit the document, and check that the table fits without clipping or unexpectedly overflowing.

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

3. Generate the PDF with CSS page size enabled

const pdf = await page.pdf({
  format: 'A4',
  preferCSSPageSize: true,
});

Puppeteer’s PDF rendering uses print CSS. preferCSSPageSize: true tells it to give CSS @page size precedence over PDF options such as format, width, or height. Without it, the documented default is false, and the content is scaled to fit the paper size instead. This option does not activate page-number selection or guarantee support for every paged-media feature.

Complete minimal Puppeteer example

The following assumes your HTML is already available as a string and Puppeteer is installed in the project. It creates a PDF file, but the mixed-page behavior still needs to be checked in your deployed browser build.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
const puppeteer = require('puppeteer');
const fs = require('node:fs/promises');

async function writeReportPdf(html) {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.setContent(html, { waitUntil: 'networkidle0' });

    const pdf = await page.pdf({
      format: 'A4',
      preferCSSPageSize: true,
    });

    await fs.writeFile('report.pdf', pdf);
  } finally {
    await browser.close();
  }
}

const html = `<!doctype html>
<html>
<head>
  <style>
    @page { size: A4 portrait; margin: 15mm; }
    @page wide { size: A4 landscape; margin: 12mm; }
    .wide-section {
      page: wide;
      break-before: page;
      break-after: page;
    }
  </style>
</head>
<body>
  <h1>Report</h1>
  <p>Portrait introduction.</p>
  <section class="wide-section">
    <h2>Wide data</h2>
    <p>Place the wide table here.</p>
  </section>
  <p>Portrait conclusion.</p>
</body>
</html>`;

writeReportPdf(html).catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

networkidle0 is used here as a practical example for pages that need their network activity to settle before capture; it is not a guarantee that every external asset or application has finished rendering. If the report is already loaded in a Puppeteer page, use its existing content and call page.pdf() with the same PDF options.

When the requirement is by final PDF page number

If the instruction is literally “make pages 3 and 7 landscape,” CSS named pages alone do not reliably express that requirement. The final page numbers are outputs of pagination, not stable identifiers for source content. A paragraph added earlier, a font change, different margins, or a paper-size change can shift which content lands on those pages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Divide the document into ordered sections whose intended page dimensions are known.
  2. Render each section separately, setting portrait or landscape for that section’s PDF generation.
  3. Merge the resulting PDFs in the required page order with a PDF-processing library appropriate to your application.
  4. Inspect the combined file for page order, page dimensions, margins, headers, and footers.

This approach adds a merge step and means you must manage boundaries between sections. It is preferable when exact final output dimensions matter more than keeping everything in a single browser print operation. The Puppeteer API options described here do not specify a particular merger, so choose and validate one for your environment.

What the relevant Puppeteer PDF options do

Option or feature What it controls What it does not do
landscape A Boolean document-level setting for printing in landscape. It does not take a per-page orientation list.
pageRanges Which document pages are included in the output; examples include 1-5, 8, 11-13. It does not change the orientation of included pages.
preferCSSPageSize Whether CSS @page size takes precedence over PDF paper-size options. Its documented default is false. It does not select pages or enable unsupported CSS selectors.
@page and named pages Print page size and margin rules, with a named style assignable to identifiable content. Standards descriptions alone do not prove support in your deployed Chromium build.

Because Puppeteer’s package and bundled browser versions can differ between deployments, check the versions you actually run and verify the output file rather than assuming a CSS feature works because it appears in a standards document.

Why not use a page-number selector?

W3C CSS Paged Media Level 3 is a Working Draft, and its draft material describes an @page :nth() selector. That description is not browser compatibility data, and it does not establish that the Chromium version behind a particular Puppeteer installation supports the selector. Treat page-number selectors as something to test against your target renderer, not as a universal production solution.

Even if a target browser supports a selector, a page number still depends on the generated pagination. If content shifts, the same page number may contain different material. Content-based named styles are a better fit for a known table or section; separate rendering and merging is a better fit for strict final-page requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

Check the PDF in the browser build you deploy

  • Generate a PDF using the exact Puppeteer package and Chrome or Chromium build used in production.
  • Confirm that ordinary pages use the expected portrait dimensions and the marked section uses the expected landscape dimensions.
  • Check whether the wide content stays within the page box and whether page breaks leave unwanted blank pages.
  • Repeat the check after changes to text, fonts, paper size, or margins, since those can alter pagination.
  • For merged PDFs, inspect the final combined file rather than only the individual section PDFs.

If you want screen CSS rather than print CSS, Puppeteer documents emulating the screen media type before calling page.pdf(). For ordinary PDF print layout, leave the page in its default print-media behavior and define the rules in print CSS.

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

Troubleshooting common mixed-orientation problems

Every page comes out landscape

Look for landscape: true in the PDF options. That setting applies to the generated document as a whole. Remove it for a CSS-driven mixed layout and define the page sizes in @page, then enable preferCSSPageSize.

The wide section is still portrait

Check that the element carrying page: wide matches the content, that the named rule is spelled @page wide, and that the PDF call uses preferCSSPageSize: true. Then verify named-page behavior in the exact deployed renderer; CSS syntax alone is not proof of implementation support.

The table is clipped or scaled down

Check the landscape page’s available width, its margins, and the table’s own CSS dimensions. If CSS page size is not taking precedence, the browser may scale content to fit the PDF option’s paper size. Inspect page dimensions as well as visual clipping.

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.

A new page appears before or after the wide section

The example deliberately uses both break-before and break-after to isolate the section. If it is already positioned at a page boundary, or if the section’s content spans multiple pages, those breaks may create an unwanted blank page. Adjust the break rules and inspect the resulting pagination.

Pages move after a content change

That is expected when pagination changes: final page numbers can move as the layout changes. If orientation must follow a particular content block, use a named page style. If it must follow exact page numbers in the final artifact, render and merge sections, then validate the combined output.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

Screen styling differs from the PDF

page.pdf() uses print CSS. If the page was explicitly switched to screen media, that can change which styles apply; emulate screen media only when screen styling is the intended PDF source.

Or skip the browser setup

If you need a clean screenshot of the report page rather than a PDF with selected pages in different orientations, ScreenshotNeo can return a screenshot from one GET request. It is a screenshot API, not a replacement for the mixed-orientation PDF workflow above.

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

For API parameters and response details, see the ScreenshotNeo documentation. Example cURL request:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie/consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
  • An MCP server provides screenshot and page-information tools for Claude, Cursor, and other MCP clients.
  • The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I use pageRanges to make only selected pages landscape?

No. It filters which pages appear in the generated PDF; it does not set orientation for those pages.

Does @page :nth(3) work in every Puppeteer installation?

No universal support is established. Check the exact Chromium build used by your application before relying on that draft selector.

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

Does ScreenshotNeo create a PDF with mixed page orientations?

The documented use described here is a website screenshot API. Use Puppeteer CSS page rules or a render-and-merge pipeline for mixed-orientation PDFs.

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.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair 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.