Conversion Overview
DynamicPDF HTML Converter for .NET uses the Converter class as its entry point for HTML to PDF conversion. The Converter class provides static methods for converting HTML synchronously with Converter.Convert or asynchronously with Converter.ConvertAsync.
The Converter class converts HTML from a URI, including web URLs and local files, or directly from an HTML text string. Depending on the overload used, the generated PDF can be saved to an output file or returned as a byte array for further processing within your application.
HTML conversion using DynamicPDF HTML Converter is performed using the static Converter.Convert and Converter.ConvertAsync methods for synchronous and asynchronous HTML to PDF conversion.
Conversion Methods
The Converter.Convert static method converts HTML to PDF synchronously, while the Converter.ConvertAsync static method converts HTML to PDF asynchronously. Both methods have several overloads that also support outputting converted documents as byte arrays or files. Refer to the following documentation pages
or API documentation
for more information on using these methods.
Consider using Converter.ConvertAsync when converting a large number of HTML documents or when integrating HTML Converter into applications that use parallel, asynchronous, or non-blocking processing workflows.
Properties
The Converter class has the following static properties for customizing how HTML Converter converts HTML to PDF.
If you have a Chromium-based browser installed and are satisfied with the default temporary directory settings, you typically do not need to modify these properties.
Because the Converter class is used statically, refer to the ConversionOptions documentation for information on specifying conversion options and customizing individual conversion operations.
Handling timeouts
You do not usually need to set default timeout values because the built-in defaults are sufficient for most conversion scenarios. If timeout control is needed, use ConversionOptions.DefaultPageLoadTimeout and ConversionOptions.DefaultConversionTimeout to separately control page-loading timeouts and overall conversion-processing timeouts rather than ConversionOptions.DefaultCommandTimeout, which does not distinguish between page-loading and overall conversion-processing operations.
- See Timeouts and Cancelation for more information.
Releasing resources
Use Converter.ReleaseResources to release cached resources when you need to recover memory or temporary storage. This is most useful after a group of conversions has completed and the application no longer needs to keep conversion resources cached.
The Converter.ReleaseResources static method releases cached resources used by the Converter class. When converting multiple HTML documents, avoid calling this method between conversions unless necessary, because releasing and reinitializing the converter resources can significantly reduce conversion performance.