How to Show the First Line on a PDF Page Without Truncation
Fix a clipped first line in PDFs by matching the remedy to the text frame, page box, font metrics, or printer boundary causing it.
Direct answer: give the first line more clearance. Increase the source text frame’s top inset or first-baseline offset, add a sufficient page top margin, or move content back inside the page box. The right fix depends on whether clipping occurs inside a text frame, at the PDF page edge, or only after printing.
Do not start by changing random font sizes. First locate the boundary that clips the glyphs, then change the setting that controls that boundary.
1. Diagnose where the first line is being cut
- Inside the text frame: the line remains in its frame, but the tops of letters are missing. Inspect the frame’s top inset and first-baseline policy.
- At the page edge: the line is positioned outside the page’s content area. Check negative margins, absolute positioning, and the page’s top margin.
- Only on paper: compare the PDF at 100% zoom with a print preview. The printer’s printable area or print scaling may cut content that is technically outside the page box.
- After a font or renderer change: compare font ascent, descent, and line-gap metrics. Different metrics can change line-box calculations and expose clipping.
Make a copy of the source document, then change one variable at a time. Record the PDF page size, font, renderer, margins, and print scale so you can reproduce the result.
2. Fix PDFs generated from HTML and CSS
For HTML-to-PDF workflows, the page margin is usually the first control to inspect. Set an explicit top margin in @page and remove negative top margins or absolute positioning that sends the heading beyond the page box.
@page {
size: A4;
margin: 24mm 18mm 20mm;
}
html, body {
margin: 0;
padding: 0;
}
h1 {
margin: 0 0 8mm;
line-height: 1.2;
}
.content {
position: static;
padding-top: 0;
}
CSS page margins are measured from the page box. Content placed outside that box can be cut by the user agent, printer, or paper cutter. See the W3C CSS 2.2 page model for the page-box and margin rules.
Common HTML/CSS causes
- A negative
margin-topon the first heading or container. position: absolutewith a negativetopvalue.- A fixed-height wrapper whose overflow is hidden.
- A zero or very small
@pagetop margin. - Transforms that move the first line above the page box.
Render a diagnostic version with a visible border around the page content and a temporary background on the first text block. If the border starts below the page edge while the glyphs extend above it, the problem is page geometry rather than the font.
3. Fix text-frame and layout-document PDFs
In a layout application, increase the text frame’s top inset, choose a first-baseline setting that leaves room for ascenders, or enable height auto-sizing when the frame is too short. These are separate controls:
| Symptom | Control to change | Why |
|---|---|---|
| Glyph tops touch the frame edge | Top inset | Adds internal clearance before the first line. |
| Baseline starts too high | First-baseline offset or policy | Moves the first baseline down inside the frame. |
| Last or first line is clipped because the frame is short | Auto-sizing or frame height | Lets the frame grow to contain the line box. |
| Text is outside the page | Page margin or object position | Moves content back inside the page box. |
Adobe’s text-layer documentation describes a constrained textPs= layer whose character cell can align tightly to the top of the text box, allowing glyphs to extend partly outside the boundary. Its example uses a 10 pt (200 twips) top margin for that particular setup. Treat that value as an example, not a universal requirement. The same documentation contrasts textPs= with text=, which shifts rendered text as needed to fit the specified box.
4. Fix an Adobe text layer or generated image layer
If you control the layer definition, leave explicit space above the first line and verify the vertical-alignment setting. A tight character-cell alignment can clip ascenders even when the page has unused space above the frame.
Text layer checklist:
- Increase the top inset.
- Move the first baseline down.
- Give the layer enough height for the complete line box.
- Avoid positioning the layer with a negative y offset.
- Re-render with the production font and renderer.
If the PDF is image-based, there is no editable text frame to resize. You may need to recreate the page from the source document or use OCR before repositioning the text.
5. Check fonts and renderers
Font ascent, descent, and line-gap metrics contribute to line-box calculations. A font substitution, missing embedded font, or renderer upgrade can therefore change whether the first line fits.
- Embed the intended font where your PDF pipeline supports embedding.
- Confirm that the renderer used in production is the same one used for review.
- Compare the output with the original font and with a known-good font.
- Recheck at 100% zoom and in print preview after every font change.
6. Printing: when the PDF looks correct on screen
If the first line is complete on screen but clipped on paper, inspect the printer’s printable area and the print-dialog scale. A printer can cut content outside its physical page area even when the PDF page itself is valid. Try “Fit” or a scale that preserves the whole page, then compare with a borderless printer or a PDF print preview.
Do not use a printer-specific margin as a universal PDF fix. The durable fix is to keep the text inside the PDF page box and leave enough top margin for the target output device.
7. A reproducible HTML-to-PDF example
The following complete document keeps the first heading inside the page area. Use it as a minimal test case before reintroducing your application’s styles.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
@page { size: A4; margin: 24mm 18mm 20mm; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 11pt/1.45 Arial, sans-serif; }
h1 { margin: 0 0 8mm; line-height: 1.2; }
p { margin: 0 0 4mm; }
</style>
</head>
<body>
<h1>A heading with room above its first line</h1>
<p>The page margin supplies clearance before the first glyphs.</p>
</body>
</html>
8. Troubleshooting checklist
| Error or symptom | Likely cause | Fix |
|---|---|---|
| Only the tops of letters disappear | Text-frame inset or baseline is too tight | Increase top inset or move the first baseline down. |
| The whole heading is missing | It is outside the page box | Remove negative positioning and increase the page top margin. |
| It fails only after changing fonts | Different ascent or line-gap metrics | Embed the intended font and rerender with the production engine. |
| It looks fine in the viewer but not when printed | Printer boundary or print scaling | Use print preview, adjust scale, and keep content inside the page box. |
| Increasing the margin does nothing | The clipping is inside a fixed-height frame | Increase frame height, enable auto-sizing, or change the frame inset. |
| Text cannot be selected | The page is an image | Return to the source layout or recreate the page with OCR assistance. |
9. Performance, reliability, and cost considerations
For batch PDF generation, deterministic layout matters more than repeatedly increasing margins. Pin the font files and renderer version, use a fixed page size, and keep a small regression document that exercises ascenders, descenders, multi-line headings, and page breaks.
When a remote service renders the PDF, account for page-load time, web fonts, JavaScript, and network-dependent assets. Set a bounded timeout, retry transient failures, and validate that the returned file has the expected page count and dimensions. Cache unchanged inputs when your workflow allows it.
10. Or skip the browser setup
ScreenshotNeo can capture a webpage as a PDF through one GET request, with paper size, margins, landscape mode, and page-range options. Its cleanup steps accept cookie banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, 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.
See the ScreenshotNeo API documentation for all options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -d format=pdf -o page.pdf
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com", "format": "pdf"},
timeout=90,
)
r.raise_for_status()
open("page.pdf", "wb").write(r.content)
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://example.com',
format: 'pdf'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const pdf = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('page.pdf', pdf);
ScreenshotNeo also provides an MCP server for Claude, Cursor, and other MCP clients, so an AI agent can call capture_pdf directly. It includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
11. FAQ
What top margin should I use?
There is no universal value. Use the smallest margin that keeps the complete line inside the page box for your font, renderer, and printer.
Why is only the first line clipped?
The first baseline is the line closest to the frame or page boundary, so an undersized inset or negative position affects it first.
Can I repair a PDF without its source?
Only if the text remains editable. Image-only pages usually require recreating the layout or applying OCR before repositioning content.
Should I change line-height?
Line-height can change the line box, but it does not correct content positioned outside the page. Fix the boundary where clipping originates.


