How to Fix CSS border-radius in iTextSharp HTML-to-PDF Conversion
When rounded corners disappear in an iTextSharp PDF, identify the parser, verify valid XHTML and CSS delivery, then test support in your exact XML Worker version.

If border-radius disappears in an iTextSharp PDF, first find out which HTML parser your code uses. HTMLWorker is limited and is not the CSS-capable path described in iText’s iText 5 guidance. XMLWorkerHelper.ParseXHtml is the documented iText 5-era route to investigate. Then ensure your input is well-formed XHTML and that the stylesheet reaches the parser. Finally, test a minimal example with the exact XML Worker version and element you need: the official sources do not establish that XML Worker supports border-radius in every release or on every element.
Do not infer legacy XML Worker behavior from a browser screenshot or from the newer pdfHTML feature list. The current pdfHTML matrix lists border-radius, but that is evidence about pdfHTML, not a compatibility promise for iTextSharp’s XML Worker. If this is a new project, consider the supported iText 7 direction and validate the exact package and deployment setup before migrating.
1. Identify the conversion path
Search the codebase for HTMLWorker, XMLWorkerHelper, and ParseXHtml. The parser determines what is reasonable to troubleshoot.
| Code path | What to expect | Next step |
|---|---|---|
HTMLWorker |
iText’s guidance describes it as limited, without CSS support in the documented scenario, and no longer developed. | Move the conversion to XML Worker if you must remain on the iText 5-era stack, or evaluate migration to iText 7/pdfHTML. |
XMLWorkerHelper.ParseXHtml |
This is the documented iText 5-era HTML conversion path with CSS handling. | Verify valid XHTML, stylesheet delivery, and the exact property/element combination against your installed version. |
| pdfHTML with iText 7 | The current pdfHTML feature matrix lists border-radius and corner-specific radius properties. |
Check the matrix and package versions matching your deployment; do not apply this result to XML Worker. |
iText’s troubleshooting material includes a case framed as “Why doesn’t CSS and RowSpan work?” Its general lesson is relevant: HTML and CSS that are accepted by a browser are not automatically valid or handled the same way by an HTML-to-PDF parser. Clean up the source before investigating the radius itself.
2. Make the smallest useful reproduction
Reduce the page to one block with explicit size, border, background, and radius. Remove framework CSS, scripts, external assets, tables, and unrelated layout rules. Use a simple block first, then reintroduce the real element type. This isolates whether the problem is markup, CSS delivery, or parser support.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<style type="text/css">
.card {
width: 240px;
height: 100px;
border: 2px solid #333333;
border-radius: 18px;
background-color: #eeeeee;
}
</style>
</head>
<body>
<div class="card">Border radius test</div>
</body>
</html>
The XHTML namespace and self-closing meta element make the document shape explicit. This sample is a diagnostic starting point, not a guarantee that a particular XML Worker version will render rounded corners. Preserve the sample and run it with the exact NuGet package versions and target element used by the application. If the minimal block rounds correctly but a table cell does not, you have narrowed the issue to markup or element-specific behavior.
3. Verify the CSS reaches XML Worker
CSS can be embedded in the HTML, linked through a stylesheet URL, or supplied separately through the overload that accepts HTML and CSS streams. For debugging, prefer a self-contained stylesheet first. If production CSS is external, confirm the URL is accessible to the conversion process, is absolute where required, and returns the expected content. If you use the separate-stream overload, make sure the CSS stream contains the rules you expect and remains available during parsing.
The following is the basic HTMLWorker-to-XML Worker conversion shape documented by iText. It assumes the application has created and opened the iText document and writer, and that html contains the XHTML above.
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
public static void ConvertHtmlToPdf(string html, string outputPath)
{
using (var output = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
using (var document = new Document())
{
var writer = PdfWriter.GetInstance(document, output);
document.Open();
using (var htmlReader = new StringReader(html))
{
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, htmlReader);
}
document.Close();
}
}
Reference the iTextSharp and XML Worker packages used by your application. The exact package versions matter, so record them with the reproduction. Keep the document open while parsing, and keep the reader or streams alive through the full call. If CSS is in a separate string, the documented guide’s shape is to encode both strings as UTF-8 byte arrays, wrap them in MemoryStream instances, and invoke the overload accepting writer, document, HTML stream, and CSS stream:
using System.IO;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
public static void ConvertWithSeparateCss(
string html, string css, string outputPath)
{
using (var output = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
using (var document = new Document())
using (var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
using (var cssStream = new MemoryStream(Encoding.UTF8.GetBytes(css)))
{
var writer = PdfWriter.GetInstance(document, output);
document.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(
writer, document, htmlStream, cssStream);
document.Close();
}
}
For this overload, make sure the HTML does not depend on a different copy of the stylesheet than the stream you provide. Avoid defining conflicting radius rules inline, in a linked file, and in the supplied CSS until the minimal case works. The official conversion guide describes these conversion forms; it does not claim a specific XML Worker release supports every CSS property.
4. Check the element and CSS rule
Once the simple block works or fails consistently, change one variable at a time:

- Keep the block dimensions and radius fixed; change only its element type to the one in the PDF.
- Keep the element fixed; change only how the CSS arrives (embedded, linked, or separate stream).
- Try a modest uniform radius before testing corner-specific declarations or percentages.
- Check for later CSS rules that override
border-radius, and remove shorthand/longhand conflicts during diagnosis. - Compare the PDF output at a consistent zoom level and inspect the edge itself, not only a thumbnail.
A visible square outline can also be a clipping or layout issue rather than proof the radius declaration was parsed. For example, if a child background paints beyond a rounded border, the visual result may differ from what you expect. Reduce the case until only the rounded element remains. These steps help diagnose; they do not imply unsupported elements or clipping behavior for any particular release.
5. Choose between staying on XML Worker and migrating
The iTextSharp repository marks iTextSharp as end of life, says only security fixes will be added, and recommends iText 7 for new projects. The current pdfHTML feature matrix lists uniform and corner-specific radius properties for pdfHTML 6.3.3 with iText Core 9.7.0. That makes migration a reasonable option to evaluate when the needed CSS behavior blocks a legacy implementation.
Before migrating, compare the exact CSS property and HTML element, verify behavior in the versions you plan to deploy, check application and deployment compatibility, and estimate the migration effort in your own codebase. The cited sources do not quantify migration cost. Also review applicable licensing and package requirements separately; do not assume that a CSS feature listing settles those questions.
6. Common errors and fixes
| Symptom | Likely cause | What to do |
|---|---|---|
| Every CSS rule seems ignored | The code still uses HTMLWorker, or the CSS is not being supplied in a form the chosen parser handles. |
Locate the conversion call. Move to XML Worker for the iText 5-era CSS path, then test embedded CSS before external stylesheets. |
| Inline CSS works but linked CSS does not | The parser may not be resolving the stylesheet URL, or the conversion host cannot access it. | Try an absolute URL, verify network access and response contents, or pass CSS as a separate stream. |
| Separate stylesheet appears ignored | The CSS stream may be empty, wrong-encoded, disposed too early, or inconsistent with the HTML. | Encode as UTF-8, keep the stream alive through ParseXHtml, and inspect the exact string before conversion. |
| Some markup renders while the test box does not | The test may be malformed, the class may not match, or the parser may not support the rule in that version. | Validate XHTML and use a minimal explicit selector; run the same case against the exact package versions. |
| Block rounds but table/cell corners remain square | The result may depend on the element or table structure. | Do not generalize from the block test. Build a minimal table reproduction and verify support for that case. |
| Conversion throws on otherwise browser-valid HTML | The parser expects cleaner, well-formed XML-style markup or encounters unsupported HTML/CSS. | Correct malformed nesting and void elements; progressively add the original page’s markup and styles. |
| Newer documentation says radius is supported, old output remains square | The cited feature may belong to pdfHTML rather than XML Worker. | Confirm the parser and package generation. Test on XML Worker itself or evaluate an iText 7/pdfHTML migration. |
7. Performance, reliability, and cost considerations
For a local XML Worker conversion, the primary troubleshooting cost is engineering time spent separating parser support from malformed input and missing CSS. Keep a small regression fixture containing the minimal XHTML, the package versions, and the expected PDF appearance. Re-run it when changing packages or the HTML template. Avoid repeatedly converting a full application page during diagnosis: removing unrelated assets makes failures easier to reproduce and reduces variables.
Reliability depends on using the same parser, versions, stylesheet inputs, fonts, and deployment environment in the reproduction as in production. A page that renders in a browser is not a compatibility test for a PDF parser. The source material offers no benchmark, throughput figure, or quantified migration estimate, so capacity and cost should be measured in the application’s own workload.
Or skip the browser setup
If what you need is a visual reference of a web page rather than a PDF generated by your application, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF, and its documentation covers the available options. This does not fix an iTextSharp conversion; it is a separate way to capture the page.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
ScreenshotNeo can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response reports the page verdict and billing state in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.
Create a free ScreenshotNeo account for 1,000 screenshots a month, with no card.
FAQ
Does adding border-radius to inline CSS guarantee rounded corners?
No. Inline CSS is useful for confirming that the rule reaches the parser, but the available official XML Worker sources do not establish support for every version and element.
Can I use browser output as proof XML Worker supports the same CSS?
No. Browsers and HTML-to-PDF parsers are different renderers. Test the target PDF conversion directly.
Does pdfHTML documentation apply to XML Worker?
No. The listed radius support applies to the pdfHTML versions identified in its feature matrix.
Should new projects use iTextSharp?
The iTextSharp repository identifies it as end of life and recommends iText 7 for new projects. Confirm current package, licensing, and deployment details for your use case.


