Short answer: page.setViewport() controls the browser’s layout viewport—the virtual screen used for responsive HTML and JavaScript. page.pdf() uses a separate print pipeline. It selects print CSS by default and gets its paper geometry from PDF options such as format, width, height, margins, orientation and scale, plus any CSS @page rule you explicitly allow it to use. Changing the viewport alone therefore cannot choose A4, Letter or a custom PDF page size.
Viewport and PDF paper are different coordinate systems
A viewport is the area a web page believes is visible in a browser window. Puppeteer uses it for media queries, responsive breakpoints, viewport units and scripts that read window.innerWidth or device dimensions. It can determine whether a navigation bar collapses or a three-column layout becomes one column.
A PDF is produced by Chromium’s print-to-PDF path. That path lays the document onto pages rather than onto a screen. page.pdf() uses the print CSS media type unless you change it, then applies a paper size and print geometry. A 1440-pixel viewport does not mean a 1440-pixel-wide PDF page, and setting a phone-sized viewport does not create a phone-sized PDF.
Keep the controls separate: use the viewport to select the page’s responsive state, and use PDF options or CSS @page rules to select the printed page.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
What page.pdf() actually controls
Print media is the default
PDF generation uses print CSS by default. Rules inside @media print can hide navigation, change colors or alter layout, while screen-only rules may not apply. If the PDF should look like the on-screen design, call page.emulateMediaType('screen') before generating it.
await page.emulateMediaType('screen');
await page.pdf({ path: 'screen-style.pdf', format: 'A4' });
Use the default print media when you want a document intended for paper or when the site has deliberate print styling. Do not switch media merely to make a viewport change “stick”; media choice and viewport size solve different problems.
Paper size comes from PDF options
Set a named paper with format, or provide explicit width and height. If format is present together with dimensions, format takes priority. Units accepted by Puppeteer’s PDF options can be supplied with CSS-style units such as in, cm, mm or px.
await page.pdf({
path: 'letter.pdf',
format: 'Letter',
printBackground: true
});
await page.pdf({
path: 'custom.pdf',
width: '210mm',
height: '297mm',
printBackground: true
});
Choose one source of truth. Supplying both a named format and custom dimensions usually produces a result different from what you intended because the named format wins.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →CSS @page can become authoritative
Web authors can specify paper dimensions in CSS:
@page {
size: 7in 10in;
margin: 12mm;
}
Puppeteer’s preferCSSPageSize option defaults to false. With that default, the requested PDF paper size is used and content may be scaled to fit. Set preferCSSPageSize: true when the document’s @page size should take precedence over format, width or height.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
await page.pdf({
path: 'css-sized.pdf',
format: 'A4',
preferCSSPageSize: true,
printBackground: true
});
Inspect all loaded stylesheets for @page before diagnosing a sizing problem. A hidden rule from a component library can be the reason a declared PDF format appears to be ignored.
Margins, orientation and scale change the result
Paper dimensions are only part of PDF geometry. Margins reduce the usable content rectangle; landscape: true swaps the orientation; and scale changes the rendered size. The documented default scale is 1, and the permitted range is 0.1 through 2.
await page.pdf({
path: 'landscape.pdf',
format: 'A4',
landscape: true,
margin: {
top: '15mm',
right: '12mm',
bottom: '15mm',
left: '12mm'
},
scale: 0.95,
printBackground: true
});
If text is clipped, content wraps unexpectedly or the apparent proportions are wrong, check these options before changing the viewport.
Free tools Windows power users keep installed
One-click scans. No signup required.
A complete Puppeteer workflow
Set the viewport before navigation when the site chooses its layout during startup. Then select the intended media type, wait for the page to be ready, and configure PDF paper independently.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({ headless: true });
try {
const page = await browser.newPage();
// Controls responsive layout, not PDF paper.
await page.setViewport({
width: 1280,
height: 900,
deviceScaleFactor: 1,
isMobile: false
});
await page.goto('https://example.com/report', {
waitUntil: 'networkidle0',
timeout: 30000
});
// Omit this line for print CSS; use it only for screen styling.
await page.emulateMediaType('screen');
await page.pdf({
path: 'report.pdf',
format: 'A4',
landscape: false,
margin: {
top: '16mm',
right: '14mm',
bottom: '16mm',
left: '14mm'
},
printBackground: true,
preferCSSPageSize: false,
scale: 1
});
} finally {
await browser.close();
}
Replace the URL and install Puppeteer in the project that runs this module. If the page reacts to viewport dimensions while loading, keep setViewport before goto. If it only reacts after a resize event, trigger the site’s own supported interaction rather than assuming PDF options will change the layout.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
How to choose the right settings
| Requirement | Use | What it changes |
|---|---|---|
| Responsive desktop, tablet or mobile layout | page.setViewport() before navigation |
CSS breakpoints, viewport units and screen-oriented JavaScript |
| Print-specific colors and visibility | Default PDF media | Applies print CSS and @media print |
| Screen-like styling in the PDF | page.emulateMediaType('screen') |
Uses screen media rules during printing |
| A4, Letter or another named paper | format |
PDF page dimensions; wins over width and height |
| Exact custom paper | width and height |
Custom PDF page dimensions when no format is supplied |
| Document-defined paper | preferCSSPageSize: true |
Lets CSS @page size override PDF paper options |
| Horizontal pages | landscape: true |
Orientation |
| More or less content per page | margin and scale |
Usable area and rendered size |
Why common viewport fixes fail
“I set a 1920px viewport, but the PDF is still narrow”
The viewport selected the page’s responsive state; it did not set PDF paper width. Set format or explicit dimensions. Also check margins and a possible @page rule.
“My screen layout disappears in the PDF”
That is normally print media working as designed. Remove or revise print rules, or call emulateMediaType('screen') before page.pdf().
“My custom @page size is ignored”
Enable preferCSSPageSize: true. With its default value of false, Puppeteer fits the content to the PDF paper option instead.
“Changing the viewport changes wrapping but not page dimensions”
That is expected: wrapping is responsive layout, while page dimensions are print geometry. Keep the viewport that gives the desired content arrangement and set paper separately.
“Content is cut off or unexpectedly scaled”
Check, in order, format versus dimensions, preferCSSPageSize, margins, landscape, and scale. A large margin or a scale below 1 can make content appear smaller; an oversized element can still overflow the printable area.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
“The first page is correct but later pages break”
Inspect print styles for fixed heights, absolute positioning and page-break rules. A viewport cannot repair a component whose print layout assumes one screen-sized canvas.
Reliability and performance considerations
- Wait for real readiness:
networkidle0is useful for pages that finish loading, but applications with long polling may never become idle. In those cases, wait for a specific selector or application-ready signal. - Load fonts and images: generate the PDF only after critical web fonts and lazy images have loaded; otherwise line wrapping and page breaks can change between runs.
- Reuse browsers carefully: keeping one Chromium process and creating pages per job reduces launch overhead, but close every page and browser on errors to avoid memory leaks.
- Keep options explicit: record media type, paper source, margins, orientation, scale and Puppeteer version with the generated file so a later change is diagnosable.
- Respect timeouts: navigation and PDF operations can time out independently. A slow or blocked resource is not evidence that viewport sizing is wrong.
Or skip the browser setup
If your goal is a reliable screenshot or PDF endpoint rather than maintaining Chromium code, ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, 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.
For a screenshot, make one GET request (see the ScreenshotNeo documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Its 63 options include full-page capture with lazy images, element selectors, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and page ranges, custom CSS and JavaScript, click and wait actions, request blocking, headers and cookies, user-agent and authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture for 100 URLs per call, a usage API and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
The Free plan includes 1,000 shots each month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan, and yearly billing provides two months free. Sign up for the free plan.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
FAQ
Does deviceScaleFactor set PDF resolution?
It affects screen rendering and responsive screenshots. It is not the PDF paper-size control; configure PDF dimensions and scale explicitly.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Should I use format or CSS @page?
Use PDF options for a caller-controlled standard or custom paper. Use @page with preferCSSPageSize: true when the document stylesheet owns the print specification.
Can one PDF contain portrait and landscape pages?
The documented landscape option applies to the PDF generation request. Mixed orientation requires designing separate outputs or a post-processing workflow rather than changing the viewport.
Frequently Asked Questions
Does changing the viewport ever matter to a PDF?
Yes. It can change responsive content before printing, such as which navigation or columns are rendered, but it still does not define the PDF’s paper dimensions.
What is the safest way to reproduce a PDF layout?
Fix the viewport before navigation, choose print or screen media deliberately, specify one paper-size authority, and record margins, orientation, scale and Puppeteer version.
The Bottom Line
Treat viewport configuration as responsive layout input, not PDF paper configuration. Set the viewport before navigation when the page needs it, then control media, paper size, CSS page precedence, margins, orientation and scale through the PDF workflow.
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.

