How to Convert HTML to PDF with EvoPdf
Convert URLs and HTML strings to PDFs in .NET with EvoPdf Next or Classic, including base URLs, deployment, licensing, troubleshooting, and a ScreenshotNeo alternative.
Direct answer: In a .NET application, install the EvoPdf package for your target platform, create an HtmlToPdfConverter, then call ConvertUrl for a public URL or ConvertHtml for an HTML string. Both methods return PDF bytes that you can save to disk or return from an HTTP endpoint. When your HTML contains relative images, stylesheets, scripts, or fonts, pass a base URL so EvoPdf can resolve them.
This guide focuses on EvoPdf Next, the vendor’s current Chromium-based edition, and explains where Classic differs. The examples use C# and .NET. Check the official quick start and converter overview for version-specific details.
1. Choose EvoPdf Next or Classic
| Edition | When to choose it | Package/namespace | Deployment notes |
|---|---|---|---|
| Next | New projects that need the current Chromium rendering engine and modern HTML/CSS behavior. | EvoPdf.Next.HtmlToPdf.Windows (Windows example), namespace EvoPdf.Next |
Vendor documentation lists Windows, Linux, and macOS support. Confirm the package and .NET runtime for your deployment target. |
| Classic | Existing applications that already use the original EvoPdf API. | Classic package, namespace EvoPdf |
Platform limitations and API options differ from Next. Review the migration guidance before switching. |
The vendor describes Next as a new engine with changed packages, namespace, and some moved options. Treat migration as an API and rendering change: compare representative pages before replacing Classic in production. See the Next product page for the edition comparison.
2. Install the package
For a Windows project using EvoPdf Next:
dotnet add package EvoPdf.Next.HtmlToPdf.Windows
The vendor states that the Linux and macOS packages work in the same general way. Select the package matching your operating system and target runtime, then restore and build:
dotnet restore
dotnet build
3. Convert a URL to PDF
Use ConvertUrl when the complete page is already served at an HTTP or HTTPS address.
using EvoPdf.Next;
var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertUrl("https://www.evopdf.com");
File.WriteAllBytes("page.pdf", pdf);
The call returns the complete PDF in memory. For a web endpoint, return those bytes with the PDF content type:
using EvoPdf.Next;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("pdf")]
public class PdfController : ControllerBase
{
[HttpGet("from-url")]
public IActionResult FromUrl([FromQuery] string url)
{
if (!Uri.TryCreate(url, UriKind.Absolute, out var parsed) ||
(parsed.Scheme != Uri.UriSchemeHttp && parsed.Scheme != Uri.UriSchemeHttps))
{
return BadRequest("url must be an absolute HTTP or HTTPS URL");
}
var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertUrl(parsed.ToString());
return File(pdf, "application/pdf", "page.pdf");
}
}
Validate and constrain user-supplied URLs in your own application. A PDF endpoint that fetches arbitrary addresses can expose internal services or consume excessive resources; use an allowlist, outbound network policy, and request limits where appropriate.
4. Convert an HTML string
Use ConvertHtml when your application generates the markup itself or loads it from a template.
using EvoPdf.Next;
var html = """
Invoice
Generated from an HTML string.
""";
var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertHtml(html, "https://www.evopdf.com");
File.WriteAllBytes("invoice.pdf", pdf);
Why the base URL matters
The second argument supplies the origin used to resolve relative references. For example, <img src="images/logo.png">, <link href="css/site.css">, web fonts, and scripts need a base URL when the HTML string has no document URL of its own.
var html = "<html><head><link rel=\"stylesheet\" href=\"css/site.css\"></head>" +
"<body><img src=\"images/logo.png\"></body></html>";
var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertHtml(html, "https://example.com/reports/");
File.WriteAllBytes("report.pdf", pdf);
Use an origin that can actually serve every relative resource. If the resources are private, authenticated, or generated at runtime, make them available to the converter or embed them in the HTML using data URLs where suitable.
5. Return generated PDFs from ASP.NET Core
using EvoPdf.Next;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("pdf")]
public class HtmlPdfController : ControllerBase
{
[HttpPost("from-html")]
public IActionResult FromHtml([FromBody] HtmlRequest request)
{
if (string.IsNullOrWhiteSpace(request.Html))
return BadRequest("html is required");
var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertHtml(
request.Html,
request.BaseUrl ?? "https://www.evopdf.com");
return File(pdf, "application/pdf", "document.pdf");
}
}
public sealed record HtmlRequest(string Html, string? BaseUrl);
Keep conversion in a service rather than constructing converters throughout controllers if your application needs centralized configuration, licensing, logging, or concurrency controls.
6. Licensing and evaluation output
EvoPdf’s documentation says evaluation output carries a demo watermark until a license key is configured. The Classic API exposes a LicenseKey property, and the Next quick start also describes setting a license key for production. Follow the vendor’s current licensing instructions for your edition and deployment model.
The quick-start page observed for this research listed version 14.60.1 and these prices: a USD 450 HTML-to-PDF Deployment License and a USD 1,200 HTML-to-PDF Company License. Prices, terms, supported runtimes, and redistribution rights can change, so verify them on the vendor’s current licensing page before purchase. The page describes the Deployment License as one application on one server for the licensee’s own application, while the Company License allows unlimited developers, applications, and servers and redistribution in the licensee’s applications.
7. Rendering details to verify before production
- JavaScript: Test pages whose content appears after scripts run. Rendering capabilities differ between Next and Classic.
- Print CSS: Add and test print-specific rules such as
@media printand page-break behavior. - Fonts: Ensure every web font is reachable from the conversion environment and that the required font files are licensed for server use.
- External assets: Check images, CSS, SVG, and scripts from private networks, CDNs, or authenticated endpoints.
- Relative URLs: Always pass a correct base URL for HTML strings that reference relative resources.
- Long pages: Test page breaks, repeated headers, tables split across pages, and very large images with production-sized documents.
The vendor lists HTML5, CSS3, JavaScript, web fonts, and SVG support for Next. These are vendor-stated capabilities; the supplied research contains no independent fidelity benchmark.
8. Async conversion and application design
The converter overview documents asynchronous variants in addition to the synchronous methods. Use the async API exposed by the exact EvoPdf package version you install when conversion could block request threads or when your service processes many documents.
Regardless of API style:
- Apply an HTTP request timeout around your own endpoint.
- Limit concurrent conversions so a burst cannot exhaust CPU or memory.
- Write large PDFs to a stream or temporary file when holding every result in memory is expensive.
- Record the source URL or document identifier, edition, package version, elapsed time, and failure reason for diagnosis.
- Retry only transient failures, and make retries bounded to avoid multiplying expensive browser work.
9. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| PDF contains a demo watermark | No production license key is configured. | Set the license key according to the edition’s documentation and confirm the deployment scope. |
| Images or CSS are missing from HTML-string output | Relative references have no usable document URL. | Pass a base URL to ConvertHtml, or use absolute URLs/embedded resources. |
| JavaScript-generated content is absent | The page did not finish rendering, a script failed, or the selected edition handles the page differently. | Open the same URL in the target environment, inspect script and network errors, and compare Next versus Classic behavior. |
| Web fonts fall back | Font files are unreachable, blocked, or unavailable to the runtime. | Check network access, font URLs, certificates, and server font licensing. |
| Conversion works locally but fails in deployment | Wrong OS-specific package, missing runtime dependency, restricted network, or incompatible .NET target. | Install the package for the deployment OS, confirm runtime support, and test outbound access to every asset. |
| Request times out | Slow page resources, scripts, a huge document, or too much concurrency. | Reduce resource and script cost, bound page size, raise the application timeout carefully, and cap parallel conversions. |
| Content is cut off or page breaks look wrong | Print CSS, oversized elements, or tables that cannot split cleanly. | Add print styles and explicit break rules, then test with realistic data and page sizes. |
| Private page cannot be rendered | The converter cannot authenticate to the page or its assets. | Expose resources through an authorized conversion path and verify that cookies, headers, and network access are supported by your selected edition. |
10. Performance, reliability, and cost notes
Performance
- Reuse a configured conversion service where supported by your package, but verify thread-safety and lifecycle guidance in the version you deploy.
- Keep HTML, images, and fonts as small as practical. Large images and client-side applications increase rendering time and memory use.
- Cache stable source pages or generated PDFs at your application layer when the document does not change for every request.
- Measure conversion time and peak memory with representative pages; the research provides no independent EvoPdf benchmark.
Reliability
- Make source URLs deterministic and log the exact input used for failed jobs.
- Use bounded retries for transient network errors only.
- Validate the resulting byte array and content type before storing or returning it.
- Keep a fallback or reprocessing queue for documents whose external assets are temporarily unavailable.
Cost
EvoPdf is a licensed .NET component. Budget for the license that matches your application and server distribution, plus the compute, storage, and network cost of rendering. Confirm current vendor pricing and terms before committing.
11. Or skip the browser setup
If you only need a screenshot or PDF from a URL, ScreenshotNeo provides a hosted HTTP API and MCP server instead of requiring you to package and operate a browser renderer. Its API can return PNG, JPEG, WebP, or PDF.
One-call example (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://stripe.com -o shot.webp
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)
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 removes cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, 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 for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
12. FAQ
Can EvoPdf convert a remote URL directly?
Yes. Create an HtmlToPdfConverter and call ConvertUrl with the absolute URL.
Can I convert an HTML string without hosting it first?
Yes. Call ConvertHtml. Supply a base URL whenever the markup contains relative resources.
Which namespace should I use?
Next examples use EvoPdf.Next; Classic examples use EvoPdf. Do not mix the package and namespace from different editions.
Does the research include a speed comparison?
No. The available material contains vendor capability descriptions but no independent performance benchmark.
Should an existing Classic application migrate?
Compare platform support, package and API changes, rendering output, and migration effort against your current requirements before switching to Next.


