Skip to main content

ConversionOptions

Version: 3.0

cete.dynamicpdf.htmlconverter.conversionoptions

ConversionOptions​

Defines properties and methods for conversion options.

public class ConversionOptions
Public Class ConversionOptions

Inheritance: Object → ConversionOptions

Licensing Info​

This class is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Constructors​

ConversionOptions(Double, Double, [Optional] Double)​

Initializes a new instance of the ConversionOptions class.

public ConversionOptions(double width, double height, [double margins = 36])
Public Sub New (width As Double, height As Double, Optional margins As Double = 36)

Parameters​

Width of the page in points

Height of hte page in points

Margins of the page in points

Licensing Info​

This constructor is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

ConversionOptions(Double, Double, Double, Double)​

Initializes a new instance of the ConversionOptions class.

public ConversionOptions(double width, double height, double leftAndRightMargins, double topAndBottomMargins)
Public Sub New (width As Double, height As Double, leftAndRightMargins As Double, topAndBottomMargins As Double)

Parameters​

Width of the page in points

Height of hte page in points

Left and right margins of the page in points

Top and bottom margins of the page in points

Licensing Info​

This constructor is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

ConversionOptions([Optional] PageSize, [Optional] PageOrientation, [Optional] Double)​

Initializes a new instance of the ConversionOptions class.

public ConversionOptions([PageSize size = Letter], [PageOrientation orientation = Portrait], [double margins = 36])
Public Sub New (Optional size As PageSize = Letter, Optional orientation As PageOrientation = Portrait, Optional margins As Double = 36)

Parameters​

Size of the page

Orientation of the page

Margins of the page in points

Licensing Info​

This constructor is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

ConversionOptions(PageSize, PageOrientation, Double, Double)​

Initializes a new instance of the ConversionOptions class.

public ConversionOptions(PageSize size, PageOrientation orientation, double leftAndRightMargins, double topAndBottomMargins)
Public Sub New (size As PageSize, orientation As PageOrientation, leftAndRightMargins As Double, topAndBottomMargins As Double)

Parameters​

Size of the page

Orientation of the page.

The left and right margins of the page in points.

The top and bottom margins of the page in points.

Licensing Info​

This constructor is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Properties​

Author​

Gets or sets the Author for metadata in converted PDF.

public string Author { get; set; }
Public Property Author As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

BottomMargin​

Gets or sets the bottom margin of the page in points.

public double BottomMargin { get; set; }
Public Property BottomMargin As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

CancelToken​

Gets or sets a CancellationToken for conversion task.

public CancellationToken CancelToken { get; set; }
Public Property CancelToken As CancellationToken

Property Value​

CancellationToken

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Examples​

Following code will cancel the conversion if it does not finish within a second.

ConversionOptions conversionOptions = new ConversionOptions(PageSize.A4, PageOrientation.Portrait, 20);
CancellationTokenSource tokenSource = new CancellationTokenSource();
conversionOptions.CancelToken = tokenSource.Token;
System.Threading.Tasks.Task.Run(() => { Thread.Sleep(1000); tokenSource.Cancel(); });
byte[] pdf = await Converter.ConvertAsync(new Uri("http://www.dynamicpdf.com"), conversionOptions);

Remarks​

This property will be used to create the task for conversion, so that the task may be cancelled if needed.

Creator​

Gets or sets the Creator for metadata in converted PDF.

public string Creator { get; set; }
Public Property Creator As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

DefaultCommandTimeout​

Gets or sets a default timeout value for each stages of conversion in milliseconds. The task will be cancelled when the timeout occurs before CancelToken .

public static int DefaultCommandTimeout { get; set; }
Public Shared Property DefaultCommandTimeout As Int32

Property Value​

Int32

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Remarks​

Until set explicitely, it is defined as a fixed fraction of DefaultConversionTimeout . It is simpler to use DefaultConversionTimeout unless you explicitely need to fine tune the performance.

DefaultConversionTimeout​

Gets or sets a default timeout value for completion of the entire conversion in milliseconds. The task will be cancelled when the timeout occurs before CancelToken .

public static int DefaultConversionTimeout { get; set; }
Public Shared Property DefaultConversionTimeout As Int32

Property Value​

Int32

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

DefaultPageLoadTimeout​

Gets or sets a default timeout value for completion of navigating to a URI or loading a HTML string in milliseconds. The task will be cancelled when the timeout occurs before CancelToken .

public static int DefaultPageLoadTimeout { get; set; }
Public Shared Property DefaultPageLoadTimeout As Int32

Property Value​

Int32

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Remarks​

Until set explicitely, it is defined as a fixed fraction of DefaultConversionTimeout . It is simpler to use DefaultConversionTimeout unless you explicitely need to fine tune the performance.

Gets or sets Footer

public string Footer { get; set; }
Public Property Footer As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Examples​

Following code will add a footer with the URL on left side and total number of pages on right side of the footer.

ConversionOptions conversionOptions = new ConversionOptions(PageSize.A4, PageOrientation.Portrait, 20);
conversionOption.Footer = "<div style='text-align:left; display:inline-block; padding-right:1em; font-size:15em;'><span class=url></span></div>"+ "<div style = 'text-align:center; display:inline-block; padding-right:1em; font-size:15em;'></div>"+ "<div style = 'text-align:right; display:inline-block; padding-right:1em; font-size:15em;'><span class=totalPages></span></div>";

Remarks​

Default is an empty string which generates no footer. Assigning null to this property will generate default footer by the browser. HTML template for the print footer should be valid HTML markup with following classes used to inject printing values into them:

date: formatted print date title: document title url: document location pageNumber: current page number totalPages: total pages in the document

For example, {span class=title}{/span} would generate span containing the title.

Gets or sets Header

public string Header { get; set; }
Public Property Header As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Examples​

Following code will add a header with the URL on left side and total number of pages on right side of the header.

ConversionOptions conversionOptions = new ConversionOptions(PageSize.A4, PageOrientation.Portrait, 20);
conversionOption.Header = "<div style='text-align:left; display:inline-block; padding-right:1em; font-size:15em;'><span class='url'></span></div>"+ "<div style = 'text-align:center; display:inline-block; padding-right:1em; font-size:15em;'></div>"+ "<div style = 'text-align:right; display:inline-block; padding-right:1em; font-size:15em;'><span class='totalPages'></span></div>";

Remarks​

Default is an empty string which generates no header. Assigning null to this property will generate default header by the browser. HTML template for the print header should be valid HTML markup with following classes used to inject printing values into them:

date: formatted print date title: document title url: document location pageNumber: current page number totalPages: total pages in the document

For example, {span class=title}{/span} would generate span containing the title.

Height​

Gets or sets the width of the page in points.

public double Height { get; set; }
Public Property Height As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

IncludeBackground​

Gets or sets the include back ground in bool.

public bool IncludeBackground { get; set; }
Public Property IncludeBackground As Boolean

Property Value​

Boolean

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Keywords​

Gets or sets the Keywords for metadata in converted PDF.

public string Keywords { get; set; }
Public Property Keywords As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

LeftMargin​

Gets or sets the left margin of the page in points.

public double LeftMargin { get; set; }
Public Property LeftMargin As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Logging​

Gets or sets the Temporary directory path.

public static LogConfig Logging { get; }
Public Shared Property Logging As LogConfig

Property Value​

LogConfig

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Examples​

This example shows how to use the TemporaryDirectory property.

Imports ceTe.DynamicPDF.Conversion

Module Module1

Sub Main()

' Assign level of logging to log config.
ConversionOptions.Logging.Level = LogLevel.Warning

' Call convert method to do conversion.
Converter.Convert("<h1>Hello World</h1>", "C:\MyOutput.pdf")

End Sub

End Module
using System;
using ceTe.DynamicPDF.Conversion;

class MyClass
{
static void Main()
{
//Assign level of logging to log config.
ConversionOptions.Logging.Level = LogLevel.Warning;

// Call convert method to do conversion.
Converter.Convert(@"<h1>Hello World</h1>", @"C:\MyOutput.pdf");
}
}

OverrideCssPageSize​

Gets or sets the override css page size in bool.

public bool OverrideCssPageSize { get; set; }
Public Property OverrideCssPageSize As Boolean

Property Value​

Boolean

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Producer​

Gets or sets the Producer for metadata in converted PDF.

public string Producer { get; set; }
Public Property Producer As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

RightMargin​

Gets or sets the right margin of the page in points.

public double RightMargin { get; set; }
Public Property RightMargin As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Subject​

Gets or sets the Subject for metadata in converted PDF.

public string Subject { get; set; }
Public Property Subject As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Title​

Gets or sets the Title for metadata in converted PDF.

public string Title { get; set; }
Public Property Title As String

Property Value​

String

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

TopMargin​

Gets or sets the top margin of the page in points.

public double TopMargin { get; set; }
Public Property TopMargin As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Width​

Gets or sets the width of the page in points.

public double Width { get; set; }
Public Property Width As Double

Property Value​

Double

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Zoom​

Determines the magnification level for the HTML. [0.1 to 2.0]

public float Zoom { get; set; }
Public Property Zoom As Single

Property Value​

Single

Licensing Info​

This property is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

Remarks​

Value ranges from 0.1 to 2.0. 1 indicates 100%

Methods​

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

Licensing Info​

This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

Licensing Info​

This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

Licensing Info​

This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

Licensing Info​

This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:

See Also​

ceTe.DynamicPDF.HtmlConverter