DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

How to Render a Webpage to PDF with a Custom Paper Size

Set custom PDF page dimensions in a webpage’s print CSS or control them in Puppeteer and Playwright, with examples and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To render a webpage as a PDF at a custom size, set the dimensions either in the page’s print stylesheet with CSS @page or in your browser automation script with explicit width and height. Use CSS when the page’s print styles should own the result; use API dimensions when the script should control it. In Puppeteer or Playwright, enable preferCSSPageSize: true if the stylesheet’s size should override API dimensions.

Choose whether CSS or your script controls the page size

Approach Use it when What controls the PDF dimensions
CSS @page The webpage’s print styles should define its paper size and margins, or the sizing should be shared by print workflows. The stylesheet, when the PDF tool honors CSS page sizing.
API width and height Your automation script should produce a chosen size regardless of the page’s styles. The PDF-generation options, unless a format setting or preferred CSS page size takes precedence.

Both Puppeteer and Playwright support width and height in physical units. Their format option takes precedence over width and height, so avoid setting conflicting values. If you want CSS sizing to win in either library, set preferCSSPageSize: true. Its documented default is false; with that default, content is scaled to fit the selected paper size rather than letting CSS size take precedence. Puppeteer PDFOptions and Playwright’s PDF generation options document these behaviors.

As an Amazon Associate I earn from qualifying purchases.

Set a custom paper size in CSS

Use the @page at-rule to specify the page-box dimensions and margins. The example below sets a portrait page measuring 8.5 by 11 inches, with 12 mm margins, and hides an element intended only for screen viewing:

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.
@page {
  size: 8.5in 11in;
  margin: 12mm;
}

@media print {
  .screen-only {
    display: none;
  }
}

Use physical units such as in, cm, or mm so the intended page dimensions are clear. The order of the two dimensions sets width and height; use 11in 8.5in for the corresponding landscape dimensions. CSS also supports page orientation choices through size. See MDN’s @page reference for the descriptor and support details.

#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

Generate the PDF with Puppeteer

Install Puppeteer in a Node.js project, navigate to the target page, then call page.pdf() with width and height in units. This example controls the paper size from the script and includes background graphics:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'networkidle0' });

    await page.pdf({
      path: 'page.pdf',
      width: '8.5in',
      height: '11in',
      margin: {
        top: '12mm',
        right: '12mm',
        bottom: '12mm',
        left: '12mm',
      },
      printBackground: true,
    });
  } finally {
    await browser.close();
  }
})();

For CSS to set the dimensions instead, remove the explicit width and height and pass preferCSSPageSize: true. Alternatively, keep API dimensions and turn that option on when CSS @page should take precedence. Puppeteer’s PDF generation uses print media by default. To render screen styling instead, call await page.emulateMediaType('screen') before page.pdf(). Puppeteer’s Page.pdf() documentation describes its print-media behavior. Colors are adjusted for printing by default; the documentation points to -webkit-print-color-adjust when exact color rendering is needed.

Generate the PDF with Playwright

Playwright uses the same general approach: navigate, then set the PDF’s dimensions and margins in page.pdf(). This Node.js example requests a custom size and gives CSS page sizing priority:

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 #2
Printable Temporary Tattoo Paper for INKJET Printer, Custom Tattoo Sticker
  • All INKJET PRINTER COMPATIBLE: Jecqbor Printable Temporary Tattoo Paper works for all INKJET printers, dimensions of 8.5 X 11 inches with a weight of 0.34 pounds, each comes in a set of 6 with clear and complete user guides! You can make your own tattoos temporary!
  • DIY CUSTOM TATTOO STICKER: This temporary tattoo paer is ideal for kids, adults, teens, choose your favorite pattern or meaningful photo to design personalized temporary tattoo stickers for your friends, couples, family and kids. Perfect for family gatherings, bachelor parties, birthdays, holidays, cosplay(Halloween/ Christmas/ Easter/ celebrations/ Saint patricks day / Irish party), games(basketball/ soccer/ volleyball/ football), concert events (music festivals), gift giving and more.
  • EASY TO USE/ REMOVE: Paper A is printing paper, B is transparent paper (with adhesive), use an inkjet printer to print the pattern on paper A, use paper B to cover it, and then cut the pattern with a wet foam/towel to press it for 30-60 seconds, and gently peel it off. How to remove: Massage gently with an oil-based product (e.g. olive oil, baby oil, coconut oil, make-up remover) for 1-2 minutes, wipe with a cotton pad and the residue will be washed off with the oil.
  • REAL LONG-lASTING TATTOO TRANSFER PAPER: The printable Temporary tattoo that at least 48 Hours,It has bright colors, clear patterns, is firmly pasted and not easy to fall off, and looks very professional and realistic.
  • 24 HOURS AFTER-SALES SERVICE:We provide clear instructions on how to use the temporary tattoo paper. We have professional after-sales service that will solve your problems within 24 hours, if you have any questions about the quality or the use steps, please feel free to contact us! We are committed to solving problems for all customers!
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'networkidle' });

    await page.pdf({
      path: 'page.pdf',
      width: '8.5in',
      height: '11in',
      margin: {
        top: '12mm',
        right: '12mm',
        bottom: '12mm',
        left: '12mm',
      },
      printBackground: true,
      preferCSSPageSize: true,
    });
  } finally {
    await browser.close();
  }
})();

Set preferCSSPageSize: false or omit it when API dimensions should govern and CSS size should not take precedence. Playwright uses print CSS and omits background graphics by default. Its width, height, and margin values accept units; a number without units is interpreted as pixels. As with Puppeteer, a supplied format value takes priority over width and height. Refer to the Playwright API reference for the current option descriptions.

Check the generated PDF

Paper dimensions alone do not guarantee that the content fits as intended. Open the output in a PDF viewer and inspect it at the target size and in the browser/version used for generation.

  • Check for clipped text, images, or elements near page edges.
  • Confirm that the output has the expected page dimensions and orientation.
  • Look for unexpected scaling, page breaks, or blank pages.
  • Verify whether backgrounds and colors appear as required.
  • Check headers and footers if your generation options enable them.

CSS paged-media support can vary between browser versions and devices; MDN cautions that some parts may differ in support and newer features may not work in older environments. Validate the PDF where it will actually be generated.

Rank #3
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

Common problems and fixes

The PDF has the wrong dimensions

Check for a format option that overrides width and height. If CSS @page should control the size, set preferCSSPageSize: true; otherwise, remove conflicting CSS sizing or format settings and use API width and height.

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

The content is unexpectedly scaled

With preferCSSPageSize: false, CSS page size does not take precedence and content is scaled to fit the paper size. Set the option to true when CSS sizing should win, or adjust the API dimensions and margins to match your intended output.

Background colors or graphics are missing

Both APIs omit background graphics by default. Set printBackground: true when the PDF needs them.

Rank #4
Sale
Weliu Glossy Printable Vinyl Sticker Paper for Printer - 21 Sheets
  • High Quality Printable Vinyl Sticker Paper: Includes 21 sheets of glossy white printable vinyl sticker paper (8.5"x11", letter size). The smooth satin finish gives your prints a clean, professional look with vibrant colors—perfect for creating custom stickers and product labels.
  • Water-Resistant & Reliable for Daily Use:This vinyl sticker paper lets you create water-resistant labels and decals with strong adhesion. For extra durability, simply add a clear UV-resistant sealer spray to enhance waterproof performance and keep colors from fading.
  • Inkjet & Laser Printer: Designed as dependable sticker paper for printer, it works with most inkjet and laser printers (Epson, Canon, HP, Brother). The surface holds ink well without smudging and dries quickly in about 5 minutes, delivering sharp details and rich color. Also compatible with Cricut Maker, Silhouette Cameo & Scissors.
  • Tear-Resistant & Long-Lasting Vinyl: This glossy printable vinyl sticker paper is tough and durable—resistant to tearing and minor scratches. Great for everyday use, from packaging labels to decorative decals that need to last.
  • Easy DIY Personalized Stickers: Create personalized stickers for laptops, bottles, packaging, scrapbooking, and more. This sticker paper for printer sticks well to glass, plastic, wood, and metal, making it ideal for DIY projects and small business use.

The PDF does not look like the page on screen

PDF generation uses print CSS by default. In Puppeteer, call page.emulateMediaType('screen') before generating the PDF if screen media styling is intentional. Otherwise, adjust the page’s print styles.

Colors differ from the webpage

Puppeteer modifies colors for printing by default. Its documentation points to -webkit-print-color-adjust for exact color rendering; review the result in the target browser and PDF viewer.

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

Margins or content placement are wrong

Check both the @page margin and the API’s margin option. Choose one source of truth where possible, then regenerate and inspect the page edges and page breaks.

Best Value
8 Sheets Printable Temporary Tattoo Paper for INKJET PRINTER, Vibrant Color
  • Print Custom Tattoos at Home. Design and print any custom tattoo sticker you like using your favorite images, text, or artwork. Whether for fun, fashion, or cosplay tattoos, this printable tattoo transfer paper brings your ideas to life in minutes.
  • Inkjet Printer Compatible & Easy to Use. Welacer tattoo paper works with most standard inkjet printers. Simply print on the white tattoo paper sheet A, apply the clear adhesive sheet B, cut out the design, and transfer. No special tools or cutters required—perfect for any DIY tattoo kit.
  • Fun for Parties, Events & Holidays. Great for Halloween, Christmas, birthdays, school projects, or creative crafts. Use as personalized party favors or fun family tattoos. Ideal for kids, teens, women, and adults who love DIY and temporary tattoos.
  • Temporary Wear with Easy Removal. Printed tattoos typically last 1–2 days depending on placement and skin type. To remove, gently wipe with baby oil, makeup remover, or rubbing alcohol. Perfect for short-term use—no scrubbing or irritation required.
  • Safe for Most—Test Before Full Use. Designed for temporary use on skin. We suggest testing a small printed design first to check for any reaction before applying larger tattoos.
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 is a website screenshot API and MCP server that can also return PDFs. Its PDF options include paper size, margins, landscape orientation, and page ranges. Send one GET request with the page URL and PDF options; see the ScreenshotNeo API documentation for request parameters.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d format=pdf 
  -d paper_width=8.5in 
  -d paper_height=11in 
  -o page.pdf

Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can I use centimeters or millimeters for a custom PDF page size?

Yes. CSS and both APIs accept physical units; for example, specify dimensions in centimeters or millimeters instead of inches.

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

Should I use Puppeteer or Playwright for a custom-size PDF?

Both document width and height controls and CSS page-size precedence. Choose based on the automation library you already use; the documented options do not establish that one is universally better.

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. 3
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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.