How to Print Wide HTML Tables to PDF with IronPDF
Use IronPDF print CSS, landscape paper, tuned margins and width controls to export wide HTML tables without clipped columns.
Use ChromePdfRenderer, enable print CSS, render in landscape, and tune the paper size and margins before saving the PDF. A wide table is usually clipped because the printable width is smaller than the table’s minimum width, responsive screen CSS switches to a narrow layout, or a document-level @page rule overrides your IronPDF settings.
The baseline is:
- Set
CssMediaType = PdfCssMediaType.Print. - Set
PaperOrientation = PdfPaperOrientation.Landscape. - Choose an appropriate paper size or a custom width.
- Reduce left and right margins only as far as readability allows.
- Add print CSS that preserves the table layout and controls wrapping.
- Check for an
@pagerule that overridesRenderingOptions.
Complete IronPDF example
This C# example renders an HTML string, uses print media rules, and saves a landscape A4 PDF:
using IronPdf;
using IronPdf.Rendering;
var html = @"<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<style>
@media print {
@page { size: A4 landscape; margin: 10mm; }
* { box-sizing: border-box; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; }
th, td {
border: 1px solid #bbb;
padding: 4px;
overflow-wrap: anywhere;
vertical-align: top;
}
thead { display: table-header-group; }
tr { break-inside: avoid; }
}
</style>
</head>
<body>
<h1>Quarterly results</h1>
<table>
<thead>
<tr><th>Customer</th><th>Region</th><th>Orders</th><th>Revenue</th><th>Notes</th></tr>
</thead>
<tbody>
<tr><td>Acme</td><td>North America</td><td>1240</td><td>$84,200</td><td>Renewal pending</td></tr>
</tbody>
</table>
</body>
</html>";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
renderer.RenderingOptions.MarginLeft = 10;
renderer.RenderingOptions.MarginRight = 10;
renderer.RenderingOptions.MarginTop = 15;
renderer.RenderingOptions.MarginBottom = 15;
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("wide-table.pdf");
Install IronPDF in the project, then add the appropriate license configuration for your deployment. The rendering API and the HTML-to-PDF workflow are documented in the official IronPDF HTML-to-PDF tutorial.
Choose the rendering method
Render an HTML string
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("wide-table.pdf");
Use this when your application has already assembled the markup and data.
Render an HTML file
var pdf = renderer.RenderHtmlFileAsPdf("/var/reports/wide-table.html");
pdf.SaveAs("wide-table.pdf");
A file is useful when the HTML is generated by a template pipeline or must be inspected independently.
Render a URL
var pdf = renderer.RenderUrlAsPdf("https://example.com/report");
pdf.SaveAs("wide-table.pdf");
For a remote page, make sure the renderer can resolve its stylesheets, fonts, images and any authenticated resources.
How printable width is calculated
The table can use only the page width left after margins. A useful approximation is:
printable width = paper width - left margin - right margin
For example, an A4 sheet is 210 mm wide. With 10 mm margins on both sides, the table has roughly 190 mm before borders, padding and other layout effects. Landscape changes the long dimension to the horizontal axis, providing substantially more room.
| Decision | Use when | Trade-off |
|---|---|---|
| Landscape orientation | The table has many columns | Less vertical space per page |
| Larger standard paper | A4 or Letter is too narrow | May not match the reader’s printer |
| Custom paper width | The output is viewed digitally or printed on a known stock | Readers may need a compatible printer |
| One-sheet width fitting | Every column must appear on one horizontal sheet | Text can become too small |
| Multi-page horizontal design | Readability matters more than one-sheet width | Readers scan columns across sections |
Print CSS that protects wide tables
Responsive screen styles often collapse columns, hide content or switch to a narrow breakpoint during server-side rendering. Iron Software recommends print media CSS because print CSS should not normally be responsive. Put PDF-specific rules in a print stylesheet or an @media print block.
@media print {
@page {
size: A4 landscape;
margin: 10mm;
}
.report-table {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.report-table th,
.report-table td {
overflow-wrap: anywhere;
word-break: normal;
vertical-align: top;
}
.report-table thead {
display: table-header-group;
}
.report-table tr {
break-inside: avoid;
}
.no-print {
display: none !important;
}
}
table-layout: fixed versus natural layout
table-layout: fixed distributes the available width predictably and prevents one long value from expanding a column indefinitely. It works best when you define sensible column widths or allow long values to wrap. Natural layout can preserve content width better, but a single unbroken URL, identifier or stack trace may force overflow.
Long values and wrapping
Use overflow-wrap: anywhere for URLs, hashes and generated identifiers. Avoid applying aggressive word breaking to normal prose because it makes the PDF harder to read. Consider shortening display labels while keeping the full value in a note or appendix.
Repeated headers and row breaks
display: table-header-group asks the renderer to repeat the table header on subsequent pages. break-inside: avoid helps keep a row together, although a row taller than a page cannot remain intact.
IronPDF options that affect a wide table
Orientation and paper size
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
Use Letter, Legal, Tabloid or another supported standard when it matches the document’s audience. If no standard size is wide enough, use a custom paper dimension supported by your IronPDF version.
Margins
renderer.RenderingOptions.MarginLeft = 8;
renderer.RenderingOptions.MarginRight = 8;
renderer.RenderingOptions.MarginTop = 12;
renderer.RenderingOptions.MarginBottom = 12;
Margins are measured in millimeters in this API. Reducing horizontal margins increases table width, but leave enough space for printers, binding and visual separation.
Print versus screen CSS
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
If you omit this setting, screen rules may win and trigger mobile or tablet breakpoints. Print mode also makes the intended PDF layout explicit.
Width fitting
IronPDF’s VirtualPaperLayoutManager can measure the minimum HTML content width and scale it to one sheet wide where possible. A minimum width can influence scaling and responsive rules. Treat fitting as a layout aid, not a promise that every table will remain readable: fonts, padding, content length, paper size and margins determine the result.
Why @page can override your C# settings
If you set landscape in RenderingOptions but the PDF remains portrait, inspect the document CSS. The Chrome renderer prioritizes document-level CSS styling, so an @page rule can take precedence over IronPDF options. This behavior is documented in Iron Software’s CSS page-rule override guidance.
Use one source of truth:
@page { size: A4 landscape; margin: 10mm; }
Then keep the C# settings consistent with it, or remove the conflicting CSS rule and control the page through RenderingOptions. Check imported stylesheets as well as inline styles.
Fitting a table to one page width
- Measure the table’s minimum width, including cell padding and borders.
- Switch to landscape.
- Use print CSS rather than responsive screen CSS.
- Set a fixed table width of
100%within the printable area. - Use
table-layout: fixedand wrap long values. - Reduce horizontal margins carefully.
- Choose a larger or custom paper width if the result is still cramped.
- Inspect the PDF at 100% zoom before accepting additional scaling.
There is no universal zoom percentage that guarantees a readable one-page result. If the table becomes too small, split it into logical sections, move low-value columns to an appendix, or allow horizontal segmentation across pages.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Rightmost columns are cut off | Table minimum width exceeds printable width | Use landscape, larger paper, smaller margins, fixed layout and wrapping. |
| Landscape setting is ignored | An @page rule sets portrait |
Inspect all CSS and align or remove the conflicting rule. |
| Everything uses a narrow mobile layout | Screen responsive CSS is active | Set CssMediaType to Print and add non-responsive print rules. |
| One column becomes extremely wide | Long unbroken text or natural table layout | Use table-layout: fixed and overflow-wrap: anywhere. |
| Headers appear only on page one | Header group is not marked for printing | Set thead { display: table-header-group; }. |
| Rows split awkwardly | Break rules are missing or the row is too tall | Use break-inside: avoid; shorten or split oversized rows. |
| Fonts or images are missing | Assets cannot be resolved by the renderer | Use reachable URLs or embedded assets and verify authentication and certificates. |
| Styles differ from the browser | Unsupported CSS, timing or different media mode | Render with print media, simplify critical layout CSS and wait for required content before conversion. |
| PDF is readable but spans many pages | Natural content height or deliberate wrapping | Keep the width readable; adjust row density or paper size instead of forcing tiny text. |
Reliability and performance checklist
- Keep a dedicated print stylesheet so screen changes do not silently change PDF output.
- Use stable fonts and confirm they are available in the rendering environment.
- Prefer embedded or reliably hosted assets for repeatable output.
- Set explicit dimensions for images and avoid layout shifts while content loads.
- For URL rendering, ensure the page is fully populated before conversion.
- Keep tables paginatable; very large DOMs consume more memory and take longer to render.
- Generate a representative wide-table fixture in CI and inspect page count, orientation and clipping after layout changes.
- Do not assume a custom paper size will print on every physical printer.
Cost and operational considerations
IronPDF’s rendering cost depends on your application, deployment and licensing arrangement. The practical PDF costs are usually CPU, memory, storage and the time needed to render large pages. Landscape and print CSS do not by themselves guarantee a faster conversion; reducing unnecessary DOM nodes, images and fonts generally helps.
Or skip the browser setup
If you only need a clean image or PDF of a rendered page and do not want to maintain a headless browser pipeline, ScreenshotNeo provides a website screenshot API. It accepts one GET request and returns PNG, JPEG, WebP or PDF. Cookie and consent banners, newsletter popups and chat widgets are removed before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf.
See the ScreenshotNeo documentation for all options, including PDF paper size, margins, landscape mode and page ranges.
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)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo has a free plan with 1,000 screenshots per month and no card required. Paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account.
FAQ
Should I use Letter or A4?
Use the paper standard expected by your readers. The table’s available width is the paper width minus both horizontal margins, so choose landscape or a larger size when the columns need more room.
Can CSS alone force every table onto one page?
CSS can set orientation, margins, width and wrapping, but content determines whether the result remains readable. A very wide table may need a custom paper width or a multi-page design.
Why does the browser preview differ from IronPDF?
The renderer may use print media, a different responsive breakpoint, different fonts or different asset timing. Compare the effective print CSS and verify that all resources are available in the rendering environment.
Does landscape prevent vertical pagination?
No. Landscape increases horizontal space, but a table can still span many pages vertically. Repeated headers and row break rules make those pages easier to use.
When should I choose an image or PDF screenshot API instead?
Use IronPDF when your application needs controlled HTML-to-PDF layout and C# rendering options. Use a screenshot API when you want a hosted capture workflow with cookie-banner and popup cleanup, billing verdicts and an API or MCP interface.


