If rounded corners disappear from an iTextSharp PDF, the first fix is usually choosing the correct parser and proving that valid XHTML and CSS actually reach it. HTMLWorker is the wrong place to debug modern CSS; iText documents it as limited, without CSS-file support in the cited scenario, and no longer developed. For legacy iText 5 applications, investigate XML Worker, then test a minimal example with the exact package version and element you use. Do not assume that a browser or current pdfHTML result proves that XML Worker supports border-radius.
Start by identifying the conversion engine
Search the conversion code before changing the stylesheet. The class and method names tell you which CSS implementation is evaluating your markup.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
PDF Explained: The ISO Standard for Document Exchange | $14.41 | Buy on Amazon |
| 2 |
|
Adobe Acrobat 6 PDF For Dummies | $13.00 | Buy on Amazon |
| 3 |
|
Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware... | $13.39 | Buy on Amazon |
| What you find | What it means | Action |
|---|---|---|
HTMLWorker |
iText’s older, limited HTML parser. The official troubleshooting guidance describes the documented scenario as lacking CSS support and says the component is no longer developed. | Move the conversion to XML Worker if the application must remain on iText 5, or plan a migration to iText 7/pdfHTML. |
XMLWorkerHelper.GetInstance().ParseXHtml(...) |
This is the documented iText 5-era route for parsing XHTML with CSS. | Validate the XHTML, confirm stylesheet delivery, and test the exact element and package version. |
| iText 7 with pdfHTML | A newer conversion generation with its own feature matrix. | Check the pdfHTML version and licensing before relying on its documented CSS support. |
See iText’s explanation of the parser distinction in “Why doesn’t CSS and RowSpan work?” and its conversion walkthrough in “How to convert HTML to PDF?”.
Use valid XHTML and a deliberately small test case
XML Worker is not a browser. A page that looks correct in Chrome can still contain markup that the XML parser cannot consume. Start with one block, an explicit size, a border, a background, and a radius:
#1 Best Overall
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<style type='text/css'>
.card {
width: 240px;
height: 120px;
border: 2px solid #2563eb;
border-radius: 16px;
background-color: #dbeafe;
}
</style>
</head>
<body>
<div class='card'>Rounded test block</div>
</body>
</html>
- Close every element, including empty elements such as
<meta />. - Use quoted attribute values and properly nested tags.
- Begin with a block element rather than a table cell, nested layout, or a pseudo-element.
- Specify the border, dimensions, and background so you can distinguish a missing radius from a missing box.
Once this minimal document behaves as expected, add your real markup one component at a time. If the minimal case fails, changing unrelated application CSS will not identify the cause.
Make sure CSS reaches XML Worker
The official guide demonstrates two relevant forms of ParseXHtml: one that receives HTML and another that receives separate HTML and CSS streams. Choose one delivery method and verify it rather than assuming a browser-style relative URL will resolve.
Inline CSS
Inline or embedded styles keep the reproduction self-contained. This C# shape follows the documented XML Worker lifecycle; adapt namespaces and project references to your application:
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
var html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<style type='text/css'>
.card { width:240px; height:120px; border:2px solid #2563eb;
border-radius:16px; background-color:#dbeafe; }
</style>
</head>
<body><div class='card'>Rounded test block</div></body>
</html>";
using (var output = File.Create("rounded.pdf"))
using (var document = new Document())
{
var writer = PdfWriter.GetInstance(document, output);
document.Open();
using (var srHtml = new StringReader(html))
{
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, srHtml);
}
document.Close();
}
Keep the document open while parsing and keep the reader and output stream alive for the whole conversion. The example is a conversion pattern, not proof that every XML Worker release renders border-radius.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Separate HTML and CSS streams
When CSS is stored separately, convert both strings to UTF-8 bytes and pass both streams to the overload shown in iText’s guide:
using System.IO;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
byte[] htmlBytes = Encoding.UTF8.GetBytes(html);
byte[] cssBytes = Encoding.UTF8.GetBytes(css);
using (var htmlStream = new MemoryStream(htmlBytes))
using (var cssStream = new MemoryStream(cssBytes))
using (var output = File.Create("rounded.pdf"))
using (var document = new Document())
{
var writer = PdfWriter.GetInstance(document, output);
document.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document,
htmlStream, cssStream);
document.Close();
}
This avoids a missing or inaccessible stylesheet URL. If you use an absolute link instead, verify that the conversion process can read it in its deployment environment; do not assume the server’s current directory or a browser cache is available.
Rank #2
Test the exact property and element you need
The official sources do not provide a version-by-version compatibility table for border-radius in XML Worker. Consequently, there is no responsible universal answer such as “all divs work” or “all table cells fail.” Run the smallest test with the exact iTextSharp/XML Worker package versions, target framework, and element used by your application.
- Render a plain
divwith a solid border and radius. - Render the same rule on the real element, such as a table cell or nested container.
- Replace the radius temporarily with a conspicuous background and border to establish that the selector matches.
- Try each corner property separately only after the shorthand case is understood.
- Compare the generated PDF, not an HTML preview, and preserve the input and package versions with the test result.
If the plain block works but the production element does not, the issue is element support or layout interaction, not simply a missing semicolon. Use a different markup structure only after the minimal reproduction demonstrates that it changes the result.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Why browser CSS and pdfHTML documentation can mislead you
Two different comparisons are commonly confused:
- Browser versus XML Worker: browser engines implement a much broader CSS and layout model. Browser success is not evidence that XML Worker will paint the same corner.
- pdfHTML versus XML Worker: they belong to different iText generations. The current pdfHTML feature matrix lists
border-radius, plus the four corner-specific radius properties, for pdfHTML 6.3.3 released with iText Core 9.7.0. That listing is scoped to pdfHTML and is not a guarantee for legacy iTextSharp XML Worker.
Check the current matrix at iText’s pdfHTML feature support page, but apply its entries only to the stated pdfHTML release and not to an iText 5 parser.
When migration is the practical fix
The iTextSharp project repository marks iTextSharp as end of life and says: “PLEASE NOTE: iTextSharp is EOL, and has been replaced by iText 7. Only security fixes will be added”. If a required corner style is blocked by the legacy parser, migration may be more predictable than accumulating CSS workarounds.
| Decision factor | Stay on iTextSharp/XML Worker | Move to iText 7/pdfHTML |
|---|---|---|
| CSS property | Verify border-radius with a minimal reproduction for the exact version and element; no authoritative compatibility matrix is established. |
The cited pdfHTML matrix lists border-radius and corner-specific properties for pdfHTML 6.3.3 with iText Core 9.7.0. |
| Application compatibility | Least immediate code change, but constrained by the existing iText 5 integration. | Requires API, package, deployment, and licensing review before adoption. |
| Maintenance | Legacy component with only security fixes according to the repository notice. | Current product line, but verify the exact .NET package and version you will deploy. |
| Migration effort | None initially; you must isolate unsupported CSS or redesign markup. | Not quantified by iText’s sources; estimate it from your document features and integration tests. |
Do not migrate solely because a browser screenshot has rounded corners. Migrate when your tested requirements, maintenance policy, and deployment constraints justify the newer conversion stack.
Troubleshooting checklist
| Symptom | Likely cause | Fix |
|---|---|---|
| No CSS styling, including color or border | The application still uses HTMLWorker, or the stylesheet never reaches the parser. |
Locate the parser call, switch to the documented XML Worker route where appropriate, and use inline CSS or the HTML/CSS-stream overload. |
| Border appears but corners stay square | XML Worker behavior for that property or element is not established for your version. | Run the minimal block test, then the exact production element. Record the package version and use a supported alternative or migration if necessary. |
| Entire element disappears or parsing throws an XML error | Malformed HTML, unclosed tags, invalid nesting, or unescaped characters. | Validate and simplify the XHTML; add elements back incrementally. |
| Embedded styles work but linked CSS does not | The conversion process cannot resolve the URL or file path, or the CSS stream is not supplied. | Use inline CSS for diagnosis, an absolute accessible resource, or pass a UTF-8 CSS stream explicitly. |
| Test block works but a table layout fails | The target element or its layout context behaves differently from a simple block. | Keep the working block as a control, then isolate the table/cell rule and test that exact structure. |
| Works after an upgrade but fails in production | Different package versions, target frameworks, fonts, resource paths, or parser configuration. | Pin and log the conversion package versions and reproduce with production-equivalent inputs and resources. |
Operational practices for reliable PDF output
- Keep a minimal XHTML fixture in automated tests so a library update cannot silently square every corner.
- Test representative elements separately: block, nested block, table, and table cell.
- Archive the input HTML, CSS, package versions, and generated PDF for a failing case.
- Use deterministic local resources during testing; network-dependent stylesheets make parser failures harder to distinguish from connectivity failures.
- Check licensing and deployment requirements independently before shipping either the legacy or newer iText generation.
Or skip the browser setup
If your actual requirement is a clean image or PDF capture of a web page, rather than server-side conversion of HTML under your control, ScreenshotNeo provides a one-request alternative. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; 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 exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
Free tools Windows power users keep installed
One-click scans. No signup required.
For API parameters and the complete option list, see the ScreenshotNeo documentation. A direct request looks like this:
Rank #3
- Used Book in Good Condition
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same call in 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)
And in 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}`);
ScreenshotNeo includes full-page and element capture, device presets, custom CSS and JavaScript, waits, request blocking, cookies and headers, PDF controls, caching, signed links, asynchronous webhooks, bulk capture, and a usage API on every plan. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to try it.
FAQ
Is a square corner always evidence that the CSS selector failed?
No. A visible border with square corners proves that some box styling reached the output, but it does not establish that the parser supports the radius on that element. Use the minimal control and exact-element test.
Can I claim XML Worker supports every CSS property listed for pdfHTML?
No. The two conversion generations have separate implementations and documentation. Treat pdfHTML feature entries as scoped to the stated pdfHTML release.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsWhat should I preserve when reporting a rendering bug?
Provide the smallest valid XHTML, the CSS, the target element, the generated PDF, and the exact iTextSharp/XML Worker package and runtime versions. That information makes the behavior reproducible instead of anecdotal.
Frequently Asked Questions
Is a square corner always evidence that the CSS selector failed?
No. A visible border with square corners proves that some box styling reached the output, but it does not establish that the parser supports the radius on that element. Use the minimal control and exact-element test.
Can I claim XML Worker supports every CSS property listed for pdfHTML?
No. The two conversion generations have separate implementations and documentation. Treat pdfHTML feature entries as scoped to the stated pdfHTML release.
What should I preserve when reporting a rendering bug?
Provide the smallest valid XHTML, the CSS, the target element, the generated PDF, and the exact iTextSharp/XML Worker package and runtime versions. That information makes the behavior reproducible instead of anecdotal.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →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.

