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
device emulation

How to Scale Puppeteer PDFs to the Emulated Device Viewport

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

To make a Puppeteer PDF match an emulated device viewport, configure the viewport and PDF page independently. Set the viewport in CSS pixels, choose the CSS media type you want rendered, and then set the PDF paper dimensions and fit behavior. deviceScaleFactor is not the PDF page-size control: page.pdf() has its own scale option.

Why the emulated viewport does not set the PDF size

Puppeteer controls two different stages of rendering. The viewport determines the browser’s emulated layout area; its width and height are CSS pixels. The viewport also has a separate deviceScaleFactor property. PDF generation, by contrast, uses print-to-PDF settings such as paper dimensions and PDF scale.

As a result, setting a phone-sized viewport does not, by itself, produce a PDF whose page is phone-sized. Nor does increasing the emulated device pixel ratio directly enlarge the PDF page. To get the intended result, decide what layout should be captured, what dimensions each PDF page should have, and whether the content should be scaled to fit those dimensions.

Choose the CSS media type first

page.pdf() generates a PDF using the print CSS media type by default. A site may have different styles for print and screen: navigation may disappear, text sizes may change, or a layout may reflow. If the PDF should use the page’s screen styles, call await page.emulateMediaType('screen') before page.pdf(). This changes the active media type; it does not set the PDF page dimensions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.

If print styling is the desired output, leave the default media type in place and check the site’s print-specific CSS. Do not try to correct a print-versus-screen layout difference solely by changing the PDF scale.

Set the emulated device before navigation

Set the viewport or emulate a device before loading the target page. Puppeteer’s Page.emulate(device) method is a shortcut that sets the user agent and viewport and resizes the page. Puppeteer advises emulating before navigation because some sites do not expect a phone or other device profile to be applied after they have loaded.

For a custom viewport, Page.setViewport() lets you set values such as CSS-pixel width and height, device scale factor, and mobile emulation. For a named device profile, use Page.emulate(device) with a device descriptor available in the Puppeteer version you are running. Either way, confirm that the site is actually laying out at the intended viewport: the page’s own responsive behavior, including its viewport metadata, affects what you see.

Set the PDF page size and fit behavior

Choose the PDF dimensions with format, width, or height in page.pdf(), or define a page size in CSS with @page. If format is set, it takes priority over width and height; avoid specifying conflicting values and expecting the explicit width and height to win.

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.
Rank #2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
  • Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
  • Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
  • Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
  • Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
  • Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.

When the CSS @page size should control the PDF, set preferCSSPageSize: true. Its documented default is false; in that default mode, content is scaled to fit the paper size provided through the PDF options. The separate PDF scale option has a documented range of 0.1 to 2 and a default of 1. It controls PDF rendering scale, not viewport device pixel ratio.

For a viewport-shaped PDF, decide what physical or CSS-unit page dimensions make sense for the intended output, then use matching dimensions and verify the generated PDF. A viewport of 390 by 844 CSS pixels does not establish a universally correct PDF size or scale value. The right result depends on the page, media styles, chosen units, paper dimensions, and Chromium/Puppeteer version.

Runnable example: emulate a mobile viewport and create a PDF

The following Node.js example uses Puppeteer, a custom 390-by-844 CSS-pixel viewport, screen media, and explicit CSS-pixel PDF dimensions. It illustrates the separation between layout viewport and PDF page settings; it is not a universal device-to-paper conversion formula. Install Puppeteer in your project before running it, and change the URL and output path as needed.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.setViewport({
      width: 390,
      height: 844,
      deviceScaleFactor: 3,
      isMobile: true,
    });

    await page.goto('https://example.com', {
      waitUntil: 'networkidle0',
    });

    // Use screen CSS rather than page.pdf()'s print CSS default.
    await page.emulateMediaType('screen');

    await page.pdf({
      path: 'viewport.pdf',
      width: '390px',
      height: '844px',
      preferCSSPageSize: true,
      scale: 1,
    });
  } finally {
    await browser.close();
  }
})();

Here, deviceScaleFactor: 3 is a viewport property, while scale: 1 is a PDF option. The example intentionally sets them independently. If you want print styling, omit the emulateMediaType('screen') call. If the document’s CSS @page dimensions should determine the output page, keep preferCSSPageSize: true and define an appropriate @page size in the site’s CSS instead of assuming the example dimensions fit every document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
  • Create and edit PDFs. Collaborate with ease. E-sign documents and collect signatures. Get everything done in one app, wherever you go.
  • Edit text and images without jumping to another app.
  • E-sign documents or request e-signatures on any device. Recipients don’t need to log in to e-sign.
  • Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
  • Share PDFs for collaboration. Commenting features make it easy for reviewers to comment, mark up, and annotate.

Validate the output instead of guessing a scale formula

Puppeteer’s options identify the controls, but they do not establish one numeric scale formula that works for every website, stylesheet, paper size, and browser build. Inspect PDFs from representative pages and target device profiles. Check the page dimensions, whether content is clipped or unexpectedly small, and whether the rendered layout is the intended screen or print version.

  • Confirm the page loaded at the intended viewport before generating the PDF.
  • Check whether print CSS or screen CSS is active.
  • Confirm which setting controls the page size: PDF dimensions or CSS @page.
  • Check whether content is being fitted to paper or rendered using a CSS page size that takes priority.
  • Change PDF scale only after those other choices are correct, then inspect the resulting file.

Troubleshooting common sizing problems

The PDF is paper-sized instead of phone-sized

A mobile viewport does not automatically define the PDF page size. Set the intended dimensions using PDF options, or define a CSS @page size and enable preferCSSPageSize: true. Check whether format is set: when it is, it takes priority over PDF width and height.

The PDF layout does not look like the browser window

This is often a media-type mismatch. PDF generation uses print CSS by default. Call page.emulateMediaType('screen') before page.pdf() if the screen stylesheet is what you want. If the print layout is intended, inspect the site’s print styles rather than forcing screen media.

The output looks too small or too large

First check page dimensions, CSS page-size priority, and whether content is being fitted to paper. Then check PDF scale, which is independent of viewport deviceScaleFactor. Adjust one control at a time and compare the resulting PDF; changing device scale factor is not a substitute for setting PDF dimensions.

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.
Rank #4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
  • Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
  • EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
  • READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. Work with Digital certificates

The site still renders a desktop layout

Confirm that the viewport or device profile is set before navigation and that the page has loaded under that profile. Device emulation includes more than simply choosing PDF dimensions: a named device profile can also set the user agent. Responsive behavior and viewport metadata on the target site can influence the layout.

The CSS page size seems ignored

Check that preferCSSPageSize: true is set and that the page actually defines a CSS @page size. With the documented default of false, content is scaled to fit the paper size supplied to PDF generation instead of giving the CSS page size priority.

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 goal is to capture a clean website image rather than control Puppeteer’s PDF page geometry, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. This example saves a WebP screenshot of a page; see the ScreenshotNeo API documentation for options and PDF capture.

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

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.

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

Sign up for 1,000 free screenshots a month, with no card required.

Best Value
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
  • ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
  • MAXIMUM FUNCIONALITY – create interactive forms, compare PDFs, bates numbering, find and replace text or colors, convert documents, OCR engine, comment, highlight, fill out and print forms, document protection and others
  • EASY TO INSTALL AND USE – well-structured user-interface, in-program instructions, free tech support whenever you need it
  • GREAT VALUE FOR MONEY - why spend a fortune if you can have maximum functionality at a reasonable price - this also fits the requirements of companies very well

Performance, reliability, and cost considerations

With a self-hosted Puppeteer workflow, PDF work happens in your browser process: page loading and PDF generation both have to complete successfully for you to receive a file. The settings described here do not establish a universal capture time, reliability rate, or cost per PDF. Those depend on your page, runtime, infrastructure, and workload. For repeatable output, keep the Puppeteer and Chromium versions consistent in the environment that generates the PDFs, and validate after upgrading either.

For API-based captures, ScreenshotNeo bills only clean shots; its response headers report the verdict and billing status, so callers can distinguish a billable result from bot checks, blank pages, timeouts, failed loads, or cache hits. Its plans are Free: 1,000 per month; 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 gives two months free, and every feature is available on every plan. These are service plan allowances, not a performance guarantee.

Frequently asked questions

Does deviceScaleFactor make text sharper in the PDF?

The documented controls distinguish viewport device scale factor from PDF rendering scale. They do not establish a general rule that increasing device scale factor improves PDF sharpness. Judge the actual output for the target page and PDF options.

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

Can I use both CSS @page dimensions and PDF dimensions?

You can configure both, but make the intended priority explicit. With preferCSSPageSize: true, the CSS page size takes priority; otherwise the PDF options control the paper size and content is scaled to fit.

Quick Recap

Bestseller No. 1
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$99.99
Bestseller No. 2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.; Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
$99.99
Bestseller No. 3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Edit text and images without jumping to another app.; Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
$239.88
Bestseller No. 4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.; EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
$99.99
Bestseller No. 5
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
$29.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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.