Simple Conversion

The Converter class has five overloaded static Convert methods for converting from a byte array or file path and five asynchronous static ConvertAsync methods. Converting a file with no advanced options is straightforward using the Converter.Convert method.

Converting a File

The Converter class can handle all of the DynamicPDF Converter for .NET's 50 supported document types using its ten overloaded Converter.Convert static methods.

You can also use one of the specialized file converters, refer to the File Specific Converters and Conversion Options documentation topic for more information on using one of the specialized converters

The Converter class has static methods for adding a license key, converting, converting asynchronously, and converting HTML.

Conversion Options

The ConversionOptions class has options to specify how to format the created PDF. Conversion option properties include formatting the created PDF's dimensions, margins, and metadata.

Properties

The ConversionOptions class has the following properties:

Refer to the ConversionOptions API documentation for more details.

The ConversionOptions class has an AppendToPdf property that allows specifying if the created PDF should be appended to a pre-existing PDF.

Examples

The examples illustrate using the Converter class's Convert method to automatically determines the file type and convert the file to a PDF. The Convert method can also handle other file types (see Converter Features for a file type listing).

Text File Conversion

ConversionOptions options = new ConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50);
Converter.Convert(@"DocumentA.txt", outputPdf, options);
Dim options As New ConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50)
Converter.Convert("DocumentA.txt", outputPdf, options)

Word File Conversion

ConversionOptions options = new ConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50);
Converter.Convert(@"DocumentA.doc", outputPdf, options);
Dim options As New ConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50)
Converter.Convert("DocumentA.doc",outputPdf, options)

HTML String Conversion

The Converter class also has a specialized method for converting an HTML string (ConvertHtmlString).

string html = "<html><body><p>Very simple HTML."
 + "</p></body></html>";
Converter.ConvertHtmlString(html, outputPdf);
Dim html As String = "<html><body><p>Very simple HTML." & "</p></body></html>"
Converter.ConvertHtmlString(html, outputPdf)

The Converter.ConvertHtmlString is intended for simple HTML documents. For more advanced conversion you might want to explore using the HtmlConverter child converter or even our specialized product for HTML conversion: DynamicPDF HTML Converter for .NET.

In this topic