Free tools Windows power users keep installed
One-click scans. No signup required.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
When iText content runs outside a PDF page, first determine whether the entire rendered layout is larger than the target page or whether one element—such as a long URL, image, table, or absolutely positioned box—escapes its own layout box. The fixes differ:
- For a globally oversized layout, change the page geometry or render on a larger intermediate page and scale the result onto the required page.
- For local text overflow, enable appropriate line breaking and adjust the offending element.
- Do not rely on CSS
overflowas a universal fix; pdfHTML documents only partial support for it.
Always inspect the generated PDF, because a declaration accepted by a browser is not automatically implemented in your pdfHTML version.
1. Identify which boundary is being exceeded
Record the target page size, margins, orientation, and the dimensions of the HTML elements that appear outside the page. There are two common classes of failure.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Global page-size mismatch
The document’s intended canvas is wider or taller than the selected PDF page. Typical examples include a desktop-width dashboard forced onto A4 portrait, a very wide table, or a deliberately large poster reduced to a standard sheet. iText’s Knowledge Base describes this case as content overlapping or rendering off the page.
#1 Best Overall
Local box overflow
The page itself is adequate, but a single item exceeds its own box. Long unbroken strings, non-wrapping table cells, oversized images, and positioned elements are frequent causes. Fixing local overflow with page scaling can make every other element unnecessarily small.
2. Let the page match the HTML when possible
Changing the PDF page size to fit the intended layout is the simplest documented choice when the output specification allows it. Choose the page size and orientation before conversion, then keep the CSS geometry consistent with that choice.
Use explicit page sizing
Define the page in CSS with @page and verify that the converter’s page event or document configuration does not override it:
@page {
size: A4 landscape;
margin: 12mm;
}
html, body {
margin: 0;
padding: 0;
}
.report {
width: 100%;
box-sizing: border-box;
}
The current pdfHTML feature matrix (baseline: pdfHTML 6.3.3 with iText Core 9.7.0) lists @page sizing as supported. Confirm the matrix for the exact dependency version in your build.
Rank #2
- Used Book in Good Condition
When a larger sheet is the right answer
Use a larger or custom page when reducing the content would harm readability, when a table must remain legible, or when the artifact is intended for a large-format printer. If consumers require A4 or Letter, use the scale-and-place method below instead.
3. Scale a large rendered page onto a fixed page
For a fixed output size, iText’s documented workflow is:
- Convert the HTML using an intermediate page large enough for the complete layout.
- Copy each intermediate page into a
PdfFormXObject. - Compute a scale that fits the object inside the required page and its margins.
- Add the scaled object to a new document whose pages have the required dimensions.
The following Java example illustrates the mechanics. Its A3-to-A4 geometry and sample coefficient are demonstration values; calculate them from your actual content and margins rather than copying the numbers blindly.
Recommended Free Tools
import com.itextpdf.forms.PdfFormXObject;
import com.itextpdf.html2pdf.ConverterProperties;
import com.itextpdf.html2pdf.HtmlConverter;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
import java.io.File;
public class ScaleHtmlPdf {
public static void main(String[] args) throws Exception {
String html = "report.html";
String intermediate = "intermediate-a3.pdf";
String output = "report-a4.pdf";
ConverterProperties props = new ConverterProperties();
props.setBaseUri(new File(html).getAbsoluteFile().getParent());
// Render on a page chosen to contain the complete HTML layout.
try (PdfWriter writer = new PdfWriter(intermediate);
PdfDocument pdf = new PdfDocument(writer)) {
pdf.setDefaultPageSize(PageSize.A3);
HtmlConverter.convertToPdf(new File(html), pdf, props);
}
try (PdfDocument source = new PdfDocument(new PdfReader(intermediate));
PdfDocument target = new PdfDocument(new PdfWriter(output))) {
PageSize outSize = PageSize.A4;
float scale = 0.4f; // example only; derive this for your content
float x = 6f; // example offset in points
float y = 350f; // example offset in points
for (int pageNo = 1; pageNo <= source.getNumberOfPages(); pageNo++) {
target.addNewPage(outSize);
PdfFormXObject pageObject = source.getPage(pageNo).copyAsFormXObject(target);
PdfCanvas canvas = new PdfCanvas(target.getLastPage());
canvas.addXObjectWithTransformationMatrix(
pageObject, scale, 0, 0, scale, x, y);
}
}
}
}
A single scale value is safe only when width and height both fit. For a content box of width Cw and height Ch, and an output area of Pw by Ph, use min(Pw/Cw, Ph/Ch), then reserve margins. If the content spans several intermediate pages, scale and place each page independently; do not assume every page has identical bounds.
Trade-offs of scaling
- Readability: shrinking a dense table may make text impractical to print or zoom.
- Margins: calculate offsets after scaling; an offset suitable for A3 is not automatically suitable for A4.
- Links and annotations: verify that copied page content and interactive features behave as required in your output workflow.
- Raster assets: scaling cannot restore detail that was already low resolution.
4. Stop long text from escaping its box
iText documents overflow-wrap and word-break as the controls for breaking long text. Natural wrapping preserves word boundaries but permits an exceptionally long token to overflow. Values such as break-word or anywhere allow breaks inside that token.
.url, .hash, .identifier {
overflow-wrap: anywhere;
word-break: break-word;
}
.cell {
white-space: normal;
max-width: 100%;
}
img {
max-width: 100%;
height: auto;
}
Choose the least aggressive rule that works for your language and typography. Breaking every word can reduce readability, while leaving hashes or URLs unbroken can force horizontal spill. Test the actual HTML with your installed pdfHTML release; browser results are not a compatibility guarantee.
5. Treat CSS support as version-specific
The feature matrix for pdfHTML 6.3.3/Core 9.7.0 lists legacy page-break-before, page-break-after, and page-break-inside support. It marks overflow as partially supported. The same matrix marks newer fragmentation properties—break-before, break-after, and break-inside—as unsupported in that baseline. Therefore, use the listed legacy properties where appropriate and check the matrix for your exact version before substituting modern CSS.
.section {
page-break-before: always;
}
.keep-together {
page-break-inside: avoid;
}
These declarations influence pagination; they do not shrink an oversized page. A table that is wider than the page still needs a geometry, wrapping, or scaling solution.
Rank #4
6. Check for pagination bugs before changing the layout
Pagination behavior can change between releases. The pdfHTML 6.3.1 release notes (Core 9.5.0) record a fix for inconsistent page-break-inside: avoid handling on HTML tables and for an infinite layout loop involving a list inside a keep-together container in a reported 960–970px height range. If your output loops, duplicates content, or places a table unexpectedly:
- Print the resolved iText and pdfHTML versions from your dependency tree.
- Reduce the input to the smallest HTML that reproduces the behavior.
- Remove
page-break-inside: avoidand keep-together wrappers temporarily to isolate the trigger. - Compare your version with the relevant release notes and test an upgrade in a controlled build.
Do not infer that the 960–970px range is a general page limit; it describes one reported scenario.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.7. A practical troubleshooting sequence
Content is cut off on the right
- Measure the widest element, including table borders, cell padding, and transformed content.
- Remove fixed pixel widths or reduce them to the available content width.
- Enable wrapping for URLs, hashes, and other unbroken tokens.
- If the whole design is intentionally wide, render on a larger intermediate page and scale it.
Content is cut off at the bottom
- Check fixed heights, absolute positioning, and negative margins.
- Replace a fixed-height container with a content-driven height where possible.
- Confirm that images have intrinsic dimensions or a bounded height.
- For a deliberately tall canvas, use intermediate pages and place each scaled page on the target page.
Page-break rules appear ignored
- Use the legacy
page-break-*properties listed for your version. - Ensure the rule is applied to a block-level element that can actually start or end a page.
- Test without nested keep-together containers.
- Check the installed pdfHTML version for known fixes.
CSS works in Chrome but not in the PDF
Compare the declaration with the pdfHTML feature matrix. Partial or unsupported properties may be silently ineffective. Replace browser-only assumptions with supported page sizing, wrapping, and pagination controls.
The scaled PDF is readable on screen but not on paper
Open the PDF at 100% and print a representative page. Increase the intermediate page’s usable area, redesign the densest component, or allow a larger output sheet rather than applying a smaller scale.
8. Validate the generated document
- Inspect the PDF’s actual media and crop boxes, not only the CSS source.
- Render every page to an image and look for clipping at all four edges.
- Check the widest table, longest token, largest image, and any positioned element.
- Verify links, fonts, selectable text, and print margins.
- Test representative inputs: short content, maximum-length strings, empty sections, long tables, and the target language’s typography.
There is no universal CSS declaration that automatically scales every HTML layout to every paper size. The reliable solution is to choose page geometry deliberately, use supported wrapping and pagination features, and validate the output.
Or skip the browser setup
If you need screenshots of the HTML before or alongside PDF work, ScreenshotNeo provides a one-request capture API. It accepts consent banners like a visitor and 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 response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
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(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
See the ScreenshotNeo documentation for options such as full-page capture, CSS selectors, device presets, custom CSS and JavaScript, waits, request blocking, cookies, geolocation, PDF page ranges, signed links, caching, asynchronous jobs, and bulk capture. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.
Frequently Asked Questions
Should I use CSS overflow:auto to fix pdfHTML clipping?
No. The pdfHTML feature matrix describes overflow support as partial, so use explicit page geometry, supported wrapping, or the documented scale-and-place workflow instead.
Are the A3, A4, 0.4 scale, and offset values universal?
No. They are values from iText’s illustrative example. Calculate scale and placement from your content bounds, target page, and margins.
Which versions should I compare when pagination is anomalous?
Check your dependency tree first. The documented matrix baseline is pdfHTML 6.3.3/Core 9.7.0, while a 6.3.1 release note records specific table and keep-together fixes.
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.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →

