The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →IronPDF’s documented approach is to render the HTML string to an in-memory PDF with ChromePdfRenderer.RenderHtmlAsPdf, then rasterize that PDF with PdfDocument.ToJpegImages. There is no single documented HTML-to-JPG method in this workflow. The result is one JPG per rendered PDF page, so page layout and pagination affect how many files you get.
Convert an HTML string to JPG in C#
Install IronPDF, pass the HTML string to RenderHtmlAsPdf, and call ToJpegImages on the returned PdfDocument. The example below writes JPGs at 150 DPI. Its filename pattern contains an asterisk, which IronPDF replaces with the page number.
Prerequisites and installation
Iron Software’s quickstart, updated September 17, 2026, lists .NET Framework 4.6.2 or later, .NET Core 3.1 or later, or .NET 5 or later, and notes that Windows requires the Visual C++ Redistributable. Install the NuGet package using the Package Manager Console:
Install-Package IronPdf
In a .NET project, you can also add the package with the .NET CLI:
#1 Best Overall
dotnet add package IronPdf
Complete example
using IronPdf;
string html = """
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
h1 { color: #1b4d7a; }
</style>
</head>
<body>
<h1>Hello IronPDF</h1>
<p>This HTML string will be rendered and exported as a JPG.</p>
</body>
</html>
""";
var renderer = new ChromePdfRenderer();
// Supply a directory when the HTML uses relative local assets.
var pdf = renderer.RenderHtmlAsPdf(html, @"C:siteassets");
// Writes output_0.jpg for page 0, output_1.jpg for page 1, and so on.
pdf.ToJpegImages(@"C:outputoutput_*.jpg", DPI: 150);
The second argument to RenderHtmlAsPdf is optional. If the HTML has no relative local assets, use renderer.RenderHtmlAsPdf(html). The method accepts HTML directly and returns a PdfDocument; the intermediate PDF does not have to be saved to disk before conversion.
How the HTML-to-JPG pipeline works
The conversion has two distinct stages. ChromePdfRenderer.RenderHtmlAsPdf lays out and renders the HTML as a PDF. IronPDF’s HTML-rendering documentation says this path supports HTML5, CSS3, JavaScript, and images. PdfDocument.ToJpegImages then rasterizes the PDF pages and saves them as JPEG files.
This matters because the JPG output reflects the PDF’s page layout, not an arbitrary single image canvas. A short document that fits on one PDF page produces one JPG. A longer document may paginate and produce several JPGs. The number of pages depends on the rendered HTML, its CSS, assets, and pagination.
Resolve stylesheets, images, scripts, and fonts
When an HTML string refers to local resources with relative URLs, provide a base path so the renderer can resolve them. For example, with a directory structure containing assets/site.css and assets/logo.png, set the base path to the assets directory and use paths relative to it in the HTML. IronPDF documents the optional BaseUrlOrPath argument for resolving relative stylesheets, images, scripts, and fonts.
Rank #2
Alternatively, use absolute file paths or remote URLs for resources, as appropriate to your application. A relative reference without a usable base path may not point to the intended file. Confirm that the process running your application can access local files and that remote resources are reachable from its environment. The HTML renderer’s support for web technologies does not guarantee that every asset can be located: the URL or path still has to resolve.
Control JPG resolution, dimensions, and pages
ToJpegImages offers overloads for DPI, page selection, maximum width and height, and form-field flattening. The basic overload uses 96 DPI by default. Choose an overload that matches the output requirement rather than assuming the PDF’s page dimensions alone determine the JPG’s pixel dimensions.
| Requirement | Documented option | What to keep in mind |
|---|---|---|
| Change raster resolution | Pass a DPI value; the basic overload defaults to 96 DPI. | Higher DPI generally produces a denser raster and larger images. Use a value suited to the consuming application. |
| Limit output size | Use an overload with nullable maximum width and height in pixels. | These are maximum dimensions, not a promise that every page will have the exact same pixel size. |
| Export only selected pages | Pass a collection of page indexes. | Indexes are zero based: the first page is index 0. |
| Include form-field values in the raster | Use the documented Flatten option. |
IronPDF describes flattening as useful when form-field values need to appear in the image. |
Use a filename pattern containing *, such as output_*.jpg, so pages receive distinct filenames. Without knowing how many pages the HTML will occupy, do not assume the conversion will create just one file.
Choose an appropriate output strategy
For a C# application that already holds markup in memory and needs a JPG, the documented IronPDF route is HTML to PdfDocument to JPEG. It offers page-level export and the resolution, dimension, and page-selection controls described above. If the requirement is a single image, first ensure the HTML lays out as one page; the renderer’s page count is determined by the document’s rendered pagination.
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 →If you only need a screenshot of an existing public webpage, that is a different input: a URL rather than an in-memory HTML string. ScreenshotNeo is a URL-based screenshot API and MCP server, not an HTML-string-to-JPG method. Its API can capture a webpage in a supported image format or PDF, but it does not replace this IronPDF example for markup held only in your C# process. See ScreenshotNeo for the service overview.
Or skip the browser setup
For a webpage URL, ScreenshotNeo can return a screenshot through one GET request. The following is the supplied cURL pattern targeting an example page; the response is saved as WebP. It does not submit an HTML string, and it is not a JPG-specific example.
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 request options. Cookie/consent banners are accepted like a visitor and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free: 1,000 screenshots a month, no card required.
Troubleshooting common conversion problems
No JPG appears where expected
- Check the output directory and ensure the application has permission to write there.
- Use a filename pattern with an asterisk, such as
output_*.jpg, for page-number substitution. - Remember that the PDF may contain more than one page, yielding multiple files rather than one image.
Relative assets are missing
Pass the directory containing the relative resources as the second argument to RenderHtmlAsPdf, or update the HTML to use resource paths that resolve in the process environment. Verify spelling, path separators, and file access for the account running the application.
Recommended Free Tools
The result is too small, too large, or soft
Set an explicit DPI instead of relying on the 96-DPI default, or use the maximum width and height overload when the consumer requires pixel bounds. These controls affect the rasterized output; they do not change how the HTML itself paginates.
Rank #4
Only some pages are wanted
Use the page-index overload and specify the needed zero-based indexes. In particular, use index 0 for the first page rather than 1.
Form values do not appear as expected
Try the documented Flatten option if form-field values must be included in the rasterized image. Its purpose in the API is to flatten those fields for the image output.
The project does not run on the target machine
Confirm that the target framework meets IronPDF’s listed minimums. On Windows, check the Visual C++ Redistributable prerequisite noted by the quickstart, and ensure the application’s account can read its assets and write the output files.
Performance, reliability, and file management
The supplied IronPDF API guidance establishes the conversion steps and available output controls, but it does not provide a benchmark for rendering speed, memory use, or JPG file size. Those depend on the HTML, asset sizes, page count, DPI, and target machine. Test with representative documents if you need to set resource limits or estimate throughput.
Best Value
For production code, use a distinct output path for each conversion so parallel or repeated runs do not overwrite one another. Ensure the destination directory exists and is writable before calling the export method. If output is consumed by another process, wait for the conversion call to complete before opening the resulting files, and handle exceptions around rendering and writing in the application’s normal error path. These are application-level safeguards; they do not change the IronPDF conversion API.
For workloads that produce multiple pages, plan for one image per selected page and manage the resulting files accordingly. Increasing DPI or exporting more pages can increase storage and transfer needs, but IronPDF’s cited API information does not state a universal file-size or performance figure.
Frequently asked questions
Can I convert HTML directly to JPG without a PDF object?
The documented IronPDF workflow described here is two-stage: render HTML to a PdfDocument, then rasterize that document with ToJpegImages. Do not treat it as a single RenderHtmlAsJpg method.
Free tools Windows power users keep installed
One-click scans. No signup required.
Does this always create one JPG?
No. It creates a JPG for each rendered PDF page included in the export. A one-page render yields one file; a multipage render can yield several.
Can I use this for HTML stored only as a string?
Yes. RenderHtmlAsPdf accepts the HTML string directly. Supply a base path if that string refers to relative local resources.
Which IronPDF versions or operating systems are covered here?
The prerequisite versions stated above come from Iron Software’s quickstart updated September 17, 2026. The cited guidance notes the Visual C++ Redistributable requirement for Windows; it does not establish a broader platform compatibility matrix here.
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.
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 errors




