What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To generate a single-page PDF with PuppeteerSharp, render your HTML in headless Chrome, make the print layout fit a deliberately chosen sheet size, and call PdfAsync with explicit dimensions and margins. Use CSS @page plus PreferCSSPageSize = true when the document should own its page size; otherwise set Width and Height (or a standard Format) in PdfOptions. PuppeteerSharp paginates whatever does not fit, so no option can turn arbitrarily tall content into one page without changing the layout or selecting a larger page.
Minimal PuppeteerSharp example
The following .NET example creates an A4-sized PDF, removes margins, waits for fonts, and prints backgrounds. The dimensions are an example, not a universal one-page setting: your content must fit inside the usable area.
using PuppeteerSharp;
using var browser = await Puppeteer.LaunchAsync(
new LaunchOptions { Headless = true });
using var page = await browser.NewPageAsync();
await page.SetContentAsync("""
<!doctype html>
<html>
<head>
<style>
@page { size: 210mm 297mm; margin: 0; }
html, body { margin: 0; }
main { box-sizing: border-box; padding: 12mm; }
</style>
</head>
<body>
<main>Content to print</main>
</body>
</html>
""");
await page.PdfAsync("output.pdf", new PdfOptions
{
Width = "210mm",
Height = "297mm",
MarginOptions = new MarginOptions
{
Top = "0",
Right = "0",
Bottom = "0",
Left = "0"
},
PreferCSSPageSize = true,
PrintBackground = true,
WaitForFonts = true
});
Install a PuppeteerSharp version compatible with the Chromium build you deploy. PDF generation currently works in Chrome headless. Open the resulting file and verify that it has exactly one page and that no content is clipped.
How PuppeteerSharp decides whether content fits on one page
Paper size is the boundary
Chrome lays out the document for print media and breaks it across sheets. The selected width, height, and margins define the available rectangle. A page that is 210mm by 297mm with 10mm margins has only 190mm by 277mm for content. Borders, padding, large headings, table rows, images, and unbreakable elements can push the final line onto a second page.
#1 Best Overall
- 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
There is no automatic “one arbitrary page” algorithm
The API exposes page-size and scaling controls, but it does not calculate a custom height for any possible HTML document. Treat one-page output as a layout decision: constrain the content, measure it in the browser, or choose a larger custom sheet. Always inspect the actual PDF rather than assuming a setting succeeded.
PageRanges is not a fitting option
PageRanges = "1" selects page one after pagination. It can silently discard content that flowed to later pages; it does not compress the document into one page. Use it only when intentionally exporting a subset of an already-paginated document.
Choose who controls the page size
| Approach | Settings | When it fits | Important behavior |
|---|---|---|---|
| Standard paper | Format = "A4" (or another supported standard) |
Invoices, reports, and documents designed for a known paper format | Format takes priority over Width and Height; do not combine them when custom dimensions are intended. |
| Custom PDF dimensions | Width and Height with units such as mm, in, or px |
Receipts, certificates, labels, or a measured single-page canvas | The dimensions become the sheet boundary. Select enough height for the complete layout. |
| CSS-owned size | CSS @page { size: ... } and PreferCSSPageSize = true |
The same print stylesheet is used in browsers and PDF jobs | CSS page size takes priority over PDF width, height, or format. |
When PreferCSSPageSize is false (the default), the PDF options control the sheet and Chrome scales content to fit that paper size according to its print behavior. Enable it deliberately when the @page rule is your source of truth.
Design the HTML for one-page output
Define the page and reset browser defaults
@page {
size: 180mm 120mm;
margin: 4mm;
}
html, body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
.sheet {
width: 100%;
min-height: 100%;
overflow: hidden;
}
Use a fixed width and height only when clipping is acceptable. For a document that must preserve every character, reduce spacing or choose a larger page instead of hiding overflow.
Control breaks and oversized elements
- Reduce heading, paragraph, and list margins in print CSS.
- Set image dimensions or
max-width: 100%so an image cannot widen the sheet. - Keep tables compact and avoid rows that are taller than the page.
- Use
break-inside: avoidfor cards or table-like blocks that must stay together, while recognizing that an unbreakable block taller than the page still cannot fit. - Remove interactive controls, navigation, and screen-only decorations from the print stylesheet.
Wait for application content, not just the initial HTML
SetContentAsync resolves when the HTML is loaded, but your application may still fetch data or render components. Wait for a selector that proves the content exists, use an application-specific delay sparingly, or wait for network idle where appropriate before calling PdfAsync. Fonts are awaited by default through WaitForFonts = true; if that wait does not resolve for a background page, activate the page with BringToFrontAsync() before generating the PDF.
Rank #2
- 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⁴
Important PdfOptions settings
| Option | Default or rule | Use it for |
|---|---|---|
Width, Height |
Unit-bearing strings; ignored when Format wins |
Custom sheet dimensions. |
Format |
Standard paper; takes priority over width and height | Common sizes such as A4 when a custom canvas is unnecessary. |
MarginOptions |
Defaults to no margins | Explicit, predictable printable area. Nonzero margins reduce room for a one-page layout. |
PreferCSSPageSize |
Default is false |
Give CSS @page size priority. |
PrintBackground |
Default is false |
Include background colors and images. |
WaitForFonts |
Default is true; waits for document.fonts.ready |
Avoid fallback-font metrics changing line wraps. |
Scale |
Permitted range 0.1–2; default 1 | Small, controlled adjustments after the layout is correct. It is not a replacement for checking pagination. |
PageRanges |
Empty string prints all pages | Select ranges such as 1-5, 8, 11-13 from an already-rendered document. |
PDF rendering uses print CSS media. If your page was designed for screen media, call await page.EmulateMediaTypeAsync(MediaType.Screen); before PdfAsync. Printed colors can also be adjusted by the browser; use -webkit-print-color-adjust: exact; when exact color reproduction is required, then verify the output because color management still depends on the actual browser and PDF viewer.
Getting the PDF as a file, bytes, or a stream
Write directly to disk
await page.PdfAsync("output.pdf", options); is the simplest form and returns after the file has been written.
Return bytes from an API
byte[] pdf = await page.PdfDataAsync(new PdfOptions
{
Format = "A4",
PrintBackground = true,
WaitForFonts = true
});
return Results.File(pdf, "application/pdf", "report.pdf");
Stream the result
PdfStreamAsync provides a stream for pipelines that should not hold the complete document in a byte array. Dispose the stream and browser when the response or job is finished.
Verifying that the result is really one page
- Open the generated PDF in a viewer and check the page count.
- Look at the bottom edge for a heading, table row, footer, or image split onto another sheet.
- Compare the rendered width and height with the intended CSS
@pageandPdfOptionsvalues. - Temporarily add an outline or contrasting background to reveal clipping and unexpected margins.
- If there are two pages, reduce content height, remove nonessential spacing, or increase the custom page height. Do not hide the second page with
PageRangesunless losing that content is intentional.
Troubleshooting common failures
The PDF has two or more pages
Cause: the content exceeds the usable area after margins, print styles, font metrics, or late-loaded assets are applied. Fix: wait for the final content, set margins explicitly, tighten the print CSS, constrain images, and choose a larger height. Check whether a CSS @page rule is overriding your options through PreferCSSPageSize.
Content is clipped
Cause: a fixed-height container, overflow: hidden, or a sheet smaller than the content. Fix: remove the clipping rule, let the container grow, or increase the page dimensions. A one-page PDF that omits content is not a successful fit.
Rank #3
- 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.
Background colors or images are missing
Cause: PrintBackground defaults to false. Fix: set PrintBackground = true and, when needed, add -webkit-print-color-adjust: exact to the print CSS.
The PDF uses the wrong size
Cause: Format overrides width and height, or PreferCSSPageSize gives @page priority. Fix: choose one owner of the size and remove conflicting settings.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Text wraps differently or fonts are missing
Cause: PDF generation started before web fonts were ready, or the deployment cannot load the font files. Fix: keep WaitForFonts = true, ensure font requests succeed, wait for your application’s readiness signal, and call BringToFrontAsync() if a background page prevents the font-ready promise from resolving.
PdfAsync times out in deployment
Cause: browser and package mismatches, a missing browser executable, or sandbox permissions. PuppeteerSharp’s deployment guidance describes a Chromium 125-and-later case in which PDF generation can require sandbox permissions. Fix: install the browser ahead of runtime, pass its executable path to LaunchAsync, and inspect InstalledBrowser.PermissionsFixed when diagnosing that environment-specific problem. Keep the Chromium and PuppeteerSharp versions aligned between development and production.
Only the first page is returned
Cause: a page range such as "1" was set. Fix: remove PageRanges while debugging and solve the underlying layout overflow.
Rank #4
- 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
Performance and reliability considerations
- Reuse a launched browser for multiple jobs when isolation requirements permit, but create a fresh page per job and close pages deterministically.
- Set an explicit readiness condition for data, images, and fonts; arbitrary sleeps make output slower without proving that the page is complete.
- Keep print CSS separate from screen CSS so changes to the interactive site do not unexpectedly alter pagination.
- Use a fixed browser executable in production and test the same Chromium build in CI to reduce rendering differences.
- Record the selected format, dimensions, margins, scale, media type, and page count with each job so a later mismatch can be reproduced.
- Do not treat scaling as a performance shortcut. A smaller scale may fit more content, but it can make text unreadable and still should be validated in the PDF.
Or skip the browser setup
If you only need a clean screenshot or PDF from a URL, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF; its PDF options include paper size, margins, landscape mode, and page ranges. The service accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response reports the result in X-Page-Verdict and X-Billed headers.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For request parameters, PDF settings, custom CSS or JavaScript, waiting rules, and signed links, see the ScreenshotNeo documentation. An MCP server supplies take_screenshot, get_page_info, and capture_pdf tools to 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 shots. Sign up for the free ScreenshotNeo plan.
Complete client examples for the same PDF workflow
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
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)
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}`);
Frequently Asked Questions
Can I force any amount of HTML onto one PDF page?
No. PuppeteerSharp paginates rendered print content. You must fit the layout into the selected page dimensions or choose a larger custom sheet.
Should I use A4 or custom width and height?
Use a standard format when the document targets ordinary paper. Use custom dimensions for receipts, labels, certificates, or a measured canvas, and avoid setting Format at the same time.
Does PuppeteerSharp generate PDFs in headed Chrome?
The documented PDF implementation currently supports Chrome headless.
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.

