Short answer: Configure the PDF sheet and the HTML canvas separately. In Rotativa, set PageSize (or both PageWidth and PageHeight), orientation, and margins. Then make the fixed-width HTML/CSS layout no wider than the printable area. A larger paper setting alone does not reflow a body whose children are absolutely positioned; you must resize or reposition that canvas, choose a wider page, or deliberately test renderer scaling.
What “100% of the page width” actually means
A PDF has two different widths:
- Physical page width: the selected paper, such as A4, Letter, or a custom width.
- Printable content width: page width minus the left and right margins.
Your Rotativa view must fit the second value. For example, a 210 mm-wide A4 page with 10 mm margins on both sides leaves 190 mm for the layout. A CSS canvas declared at 210 mm or 210 CSS pixels can therefore overflow even though the paper itself is A4.
There is a further distinction when the view uses a fixed body and absolutely positioned children. Normal flow and responsive elements can often rewrap when the viewport changes. Absolute coordinates generally do not: a box at left: 800px remains there until your CSS or renderer scales it. Treat page geometry and layout reflow as separate problems.
Set Rotativa’s page geometry explicitly
Rotativa’s MVC wrapper exposes PageSize, PageWidth, PageHeight, PageOrientation, and PageMargins. A typical action is:
#1 Best Overall
public ActionResult Invoice(int id)
{
var model = service.GetInvoice(id);
return new ViewAsPdf("Invoice", model)
{
PageSize = Rotativa.Options.Size.A4,
PageOrientation = Rotativa.Options.Orientation.Portrait,
PageMargins = new Rotativa.Options.Margins(10, 10, 10, 10)
};
}
The exact constructor and enum names can vary between Rotativa MVC packages, so confirm them against the package installed in your project. The cited MVC source describes the dimensions in millimetres. Do not copy a value from a different Rotativa or wkhtmltopdf build without checking its type and unit.
Use custom dimensions as a pair
When the standard paper sizes do not match your document, provide both custom dimensions:
return new ViewAsPdf("Blueprint", model)
{
PageWidth = 260,
PageHeight = 180,
PageOrientation = Rotativa.Options.Orientation.Landscape,
PageMargins = new Rotativa.Options.Margins(5, 5, 5, 5)
};
In the MVC wrapper source, a supplied width and height pair takes precedence over PageSize. Supplying only one dimension is unsafe: the renderer may retain a paper preset or reject the combination. Keep the pair together and verify the generated PDF.
Rank #2
Make the fixed HTML canvas fit the printable width
First calculate the target width:
- Write down the physical page width in the units used by your Rotativa version.
- Subtract the left and right margins.
- Use that result as the maximum width of the body or its containing canvas.
- Check every absolutely positioned child, including its width, right edge, and any shadows or borders.
A robust CSS pattern is to keep the design width in one variable and prevent accidental overflow:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall:root {
--printable-width: 190mm; /* A4 width 210mm - 10mm left - 10mm right */
}
html, body {
margin: 0;
padding: 0;
width: var(--printable-width);
}
.invoice-canvas {
position: relative;
width: var(--printable-width);
max-width: var(--printable-width);
box-sizing: border-box;
overflow: hidden;
}
.invoice-canvas .total {
position: absolute;
left: 150mm;
width: 35mm;
}
Use a containing block with position: relative; otherwise absolute coordinates can be resolved against an unexpected ancestor. Keep the canvas and its children in the same coordinate system. If your current artwork was authored at a wider fixed size, you have three choices:
- Resize the canvas and coordinates: preserve the design logically, but update widths, offsets, and text sizes so the rightmost element ends inside the printable area.
- Choose a wider page or landscape: preserve coordinates when the document is intentionally wide, accepting a different paper format.
- Scale at render time: useful for a controlled, fixed canvas, but test readability and clipping with the exact binary used in production.
Do not claim that changing PageWidth automatically performs any of these operations. It changes page geometry; it does not prove that CSS coordinates will reflow.
Understand viewport size and intelligent shrinking
wkhtmltopdf exposes paper size, physical width and height, orientation, margins, viewport behavior, and intelligent shrinking as separate options. Rotativa passes additional wkhtmltopdf arguments through CustomSwitches. Rotativa.AspNetCore documentation gives --disable-smart-shrinking as an example:
return new ViewAsPdf("Blueprint", model)
{
PageSize = Rotativa.Options.Size.A4,
PageMargins = new Rotativa.Options.Margins(10, 10, 10, 10),
CustomSwitches = "--disable-smart-shrinking"
};
Use this as an experiment, not a universal fix. If shrinking is currently making text unexpectedly small, disabling it may restore the intended scale; it can also expose overflow that was previously hidden by scaling. Compare both PDFs using the same wkhtmltopdf executable, fonts, viewport settings, and input data. The installed binary matters more than a switch copied from an unrelated project.
Free tools Windows power users keep installed
One-click scans. No signup required.
A repeatable diagnostic workflow
- Record the target geometry. Note paper, orientation, left margin, and right margin. Compute the printable width before editing CSS.
- Inspect the canvas. Find fixed
widthdeclarations onbody, wrappers, tables, and images. Look forposition: absoluteand children whose right edge exceeds the canvas. - Set all Rotativa properties. Use a known
PageSize, explicit orientation, and explicit margins. For custom paper, set both dimensions. - Align CSS to the printable width. Change the canvas width or select a page that accommodates it. Recalculate absolute offsets rather than changing only the outer body.
- Render a diagnostic page. Add a temporary border around the canvas and a vertical guide at the computed right edge. This reveals whether clipping occurs in CSS or at the PDF boundary.
- Test shrinking deliberately. Render once with the default behavior and once with the tested
CustomSwitchessetting. Compare right-edge clipping, text legibility, and page breaks. - Inspect the actual PDF. Check the widest page, the last positioned element, images loaded after initial HTML, and every page in a multi-page document.
Common failure modes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Right side is cut off on A5 portrait | The fixed canvas is wider than page width minus margins. | Reduce the CSS canvas and offsets, use landscape or a wider paper, or test controlled scaling. |
Changing PageSize has no visible layout effect |
Absolute children retain their coordinates; page geometry does not reflow them. | Edit the canvas/child CSS or choose geometry that contains the existing coordinate system. |
| Custom width appears ignored | Only one custom dimension was supplied, or a preset still wins. | Set PageWidth and PageHeight together and confirm the wrapper version. |
| Content is unexpectedly tiny | Intelligent shrinking is scaling a wide layout to fit. | Compare with and without --disable-smart-shrinking; then fix the underlying width or choose a wider page. |
| Content clips after changing margins | The printable width changed, but CSS retained the old canvas width. | Recompute width as page width minus both margins and update the containing element. |
| Elements move relative to the wrong origin | The absolute-positioned parent is not positioned. | Set the intended wrapper to position: relative and verify nested containing blocks. |
| Browser preview differs from the PDF | wkhtmltopdf uses its own viewport, fonts, loading timing, and binary version. | Debug with the deployed renderer, wait for required content, and inspect its output rather than relying on a desktop browser. |
| Images or web fonts are missing | Resources were not available when capture occurred, or URLs require authentication. | Use reachable URLs, provide required headers/cookies through the renderer, and wait for the relevant selector or network activity before capture. |
Choosing between CSS resizing, a wider page, and scaling
| Approach | Best fit | Trade-off to verify |
|---|---|---|
| Resize CSS canvas and coordinates | Documents that must print on a specific paper size. | Text wrapping, coordinate calculations, and image dimensions may need redesign. |
| Wider paper or landscape | Blueprints, dashboards, and other deliberately wide fixed layouts. | Readers may need landscape viewing or a nonstandard paper supply. |
| Renderer scaling | A legacy fixed canvas that must remain unchanged. | Small text, blurred raster assets, and hidden overflow are possible. |
There is no evidence of a universal setting that makes every fixed, absolute-positioned view fit every paper format. Treat the generated PDF as the acceptance test and preserve the option that keeps all required content readable.
Rank #4
- Funny saying for any front-end developer, web developer, computer programmer, computer systems engineer, mobile app developer, software developer, or code lover who likes to code, make funny programming jokes, and take memorable photos.
- Wear it proudly at International Programmers' Day, school, coding classes, or coding communities! It also makes a funny present for a computer programming lover friend.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Performance, reliability, and maintenance
- Keep geometry deterministic. Use explicit paper, margins, and dimensions instead of relying on defaults that can change with package or binary upgrades.
- Stabilize loading. A PDF captured before fonts, images, or JavaScript-rendered totals arrive can look like a width problem. Wait for the element that proves the page is ready.
- Control external resources. Network-dependent CSS, fonts, and images introduce variability. Prefer versioned assets and make authentication requirements explicit.
- Test representative extremes. Render the longest labels, largest images, empty optional sections, and the widest absolute child. A short sample can hide clipping.
- Version the renderer. Rotativa package updates and wkhtmltopdf binaries can differ in defaults and supported switches. Record the deployed versions with your PDF regression tests.
- Measure output, not assumptions. Check page count, paper size, orientation, right-edge visibility, and text legibility in automated review where possible.
Or skip the browser setup
If your goal is to capture a rendered URL rather than maintain a Rotativa server, ScreenshotNeo provides a single screenshot/PDF endpoint. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each 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. An MCP server also lets Claude, Cursor, or another MCP client call take_screenshot, get_page_info, and capture_pdf.
Use the API documentation at https://screenshotneo.com/docs/ for authentication and options. A minimal PDF or image request can start with:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper/margins/orientation/page ranges, custom CSS and JavaScript, click and wait actions, request blocking, headers/cookies/user agents, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
FAQ
Should I use millimetres or CSS pixels?
Use the units your Rotativa and CSS calculations consistently. Confirm the wrapper’s property units, then convert the design once rather than mixing physical and screen units inside absolute offsets.
Best Value
- Programming Language Lover Code Apparel. App or Web Design and Development Expert Funny Dress. Best Valentines Idea For Coding Lover. HTML Code or Meaning Costume
- Funny I Know HTML - How To Meet Ladies Computer Programmer Quotes
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Can margins differ on the left and right?
Yes. Treat each margin independently: the available width is page width minus the left margin minus the right margin. Recheck the containing canvas whenever either value changes.
Is a clipped element always outside the page?
No. Clipping can also come from an ancestor’s overflow, an oversized image, a border or shadow, or a renderer difference. Temporarily outline each container to locate the first boundary that cuts the content.
Frequently Asked Questions
Should I use millimetres or CSS pixels?
Use the units your Rotativa and CSS calculations consistently. Confirm the wrapper’s property units, then convert the design once rather than mixing physical and screen units inside absolute offsets.
Can margins differ on the left and right?
Yes. Treat each margin independently: the available width is page width minus the left margin minus the right margin. Recheck the containing canvas whenever either value changes.
Is a clipped element always outside the page?
No. Clipping can also come from an ancestor’s overflow, an oversized image, a border or shadow, or a renderer difference. Temporarily outline each container to locate the first boundary that cuts the content.
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.




