Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchFor a direct C# conversion, use a library that accepts an HTML string: IronPDF’s ChromePdfRenderer.RenderHtmlAsPdf or iText pdfHTML’s HtmlConverter.ConvertToPdf. Choose based on the HTML and CSS you need to render, how you will resolve images and stylesheets, your deployment environment, and licensing. If your input is a live web page rather than an HTML string, a screenshot service is a different approach; it captures a URL instead of replacing a .NET HTML-to-PDF library.
Choose a conversion path
Both examples below start with a string of HTML and write a PDF. IronPDF’s tutorial describes a Chromium-based renderer with support for HTML5, CSS3, JavaScript, and images. iText pdfHTML is an add-on for iText Core and provides converter properties such as a base URI for resolving relative resources. These are different rendering approaches, not interchangeable guarantees that every page will look identical. Test your own content in the library and deployment environment you intend to use.
| Need | What to consider |
|---|---|
| Browser-style HTML rendering and JavaScript | IronPDF documents a Chromium-based renderer and broad HTML5, CSS3, JavaScript, and image support. |
| An existing iText-based application | iText pdfHTML fits within the iText ecosystem and exposes converter properties, including base-URI configuration. |
| Images or stylesheets referenced by relative paths | Provide a valid asset directory or base URI so the renderer can resolve those references. |
| Commercial use | Check the current license terms for the library and add-ons before deploying. |
No comparative speed or accuracy benchmark is established here, so choose by feature fit and verify output with representative documents rather than assuming one is faster or more faithful.
Convert a string with IronPDF
IronPDF’s documented sequence is to create a ChromePdfRenderer, pass the HTML string to RenderHtmlAsPdf, and save the returned PDF document. This minimal example writes a file in the application’s working directory:
#1 Best Overall
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF</h1>");
pdf.SaveAs("pixel-perfect.pdf");
The pdf value is a PdfDocument. The example uses inline markup, so it does not depend on external files or relative paths. In a real application, supply the complete HTML and CSS your document needs, then open the generated PDF and check text, layout, images, and page breaks.
Resolve local assets
If the HTML refers to local images, stylesheets, or other assets using relative paths, IronPDF’s tutorial says to pass the asset directory as the second parameter. Use the directory that corresponds to the paths in your HTML. A correct HTML string alone is not enough if the renderer cannot locate referenced files.
For example, if a stylesheet reference is relative, check that the base directory you pass is the directory from which that reference can actually be resolved. Keep the document’s markup and the asset directory consistent, especially when the process runs from a different working directory than it does during development.
Convert a string with iText pdfHTML
For iText pdfHTML, pass the HTML string to HtmlConverter.ConvertToPdf and provide a destination stream. The basic form shown in iText’s C# example is:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →public void createPdf(string html, string dest)
{
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create));
}
When HTML includes relative images or stylesheets, configure a base URI. The URI should identify the location against which the relative resource paths in the HTML are resolved:
Rank #2
public void createPdf(string baseUri, string html, string dest)
{
ConverterProperties properties = new ConverterProperties();
properties.SetBaseUri(baseUri);
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create), properties);
}
These examples show the API shape; place them in a class and project configured with the relevant iText Core and pdfHTML dependencies. The precise dependency versions and license terms should be checked against the current iText documentation for your application. iText’s API reference documents overloads that accept a System.String containing HTML.
Use a base URI deliberately
A base URI matters whenever a resource is named relative to the HTML rather than by an absolute location. If an image renders as missing or a stylesheet appears not to load, first verify the resource path in the HTML, then verify that the configured base URI points to the intended location and that the application can access it. This applies to local assets as well as remote resources referenced by the document.
Make the HTML and output predictable
Conversion is a rendering task: the PDF depends on both the markup and the resources available to the renderer. For a reliable implementation, treat the PDF as an output artifact to validate, not merely as proof that a method returned successfully.
- Use well-formed HTML. A complete document structure is useful when styles, selectors, or relative resources depend on document context.
- Make dependencies resolvable. Check local image, font, and stylesheet paths and configure the library’s documented asset directory or base URI where needed.
- Test dynamic content explicitly. Support for JavaScript does not establish identical results for every browser API or script. Test the particular code that generates or changes the content.
- Check pagination. Review page breaks, clipped content, font substitution, and long sections in the actual PDF. A successful conversion call does not guarantee that a layout is suitable for printing.
- Validate deployment conditions. Test under the same runtime and resource-access conditions as production. Do not assume that paths or external resources available on a developer’s machine will also be available to a deployed process.
For repeated or high-volume conversion, measure your own representative workload and monitor failures and output quality in the target environment. The available documentation cited here does not establish a comparative performance figure, so a number from an unrelated setup would not be a sound basis for capacity planning.
Use current iText HTML conversion APIs
Do not start a new HTML-to-PDF implementation with iText’s HTMLWorker. iText’s Knowledge Base says: “The HTMLWorker class was deprecated many years ago.” It also explains that HTMLWorker did not support every HTML tag, did not parse CSS files, and was removed from recent versions. For current iText HTML-to-PDF conversion, use pdfHTML and its HtmlConverter API instead.
Troubleshoot common conversion problems
Images or stylesheets are missing
Likely cause: A relative path has no usable base location, or the path does not match the asset directory or URI supplied to the renderer.
Fix: Inspect the HTML resource references and configure IronPDF’s asset directory or iText’s base URI as appropriate. Check the output again after correcting the path.
The PDF is blank or incomplete
Likely cause: The HTML may be incomplete, a required asset may not resolve, or content may be produced by JavaScript that has not rendered as expected.
Fix: Test a minimal HTML string first, then add styles, assets, and dynamic content in stages. For JavaScript-driven content, verify the specific script and browser-dependent behavior separately; a general support statement does not promise identical output for every browser API.
The content runs off the page or breaks badly
Likely cause: The HTML’s layout, fonts, or page-break behavior does not suit the PDF page dimensions.
Rank #4
Fix: Inspect the generated PDF, adjust the HTML/CSS for the intended page layout, and test long text and large elements. Treat page breaks and fonts as acceptance criteria, not details to assume.
The code uses HTMLWorker or an obsolete example
Likely cause: The example targets an old iText API.
Fix: Use the current pdfHTML add-on and HtmlConverter API, and verify compatibility and licensing against the current iText documentation.
Conversion works locally but fails after deployment
Likely cause: The deployed process cannot resolve the same files or resources as the development environment.
Fix: Verify resource paths and the configured asset directory or base URI in the deployed context. Test with the runtime and access conditions the application will actually use.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
Or skip the browser setup
If your input is a public web page and your goal is a capture rather than conversion of an arbitrary HTML string, ScreenshotNeo offers a website screenshot API and MCP server. It is not a drop-in C# HTML-string converter: the call below captures the supplied URL. ScreenshotNeo also supports PDF output, but this example uses the documented WebP response and does not assume an undocumented format parameter.
For a one-call capture, use cURL (replace the target URL as needed):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for setup and available options. Before the capture, it accepts the cookie or consent banner as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status in headers. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Which approach should you use?
Use IronPDF or iText pdfHTML when your application already has an HTML string and must create a PDF from that content. Use the documented asset-directory or base-URI mechanism when the markup references relative resources. If you need iText, prefer pdfHTML over the obsolete HTMLWorker API and review licensing before commercial deployment. Use ScreenshotNeo when the task is capturing a page identified by a URL, not when you need to pass an arbitrary in-memory HTML string to a C# renderer.
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.

