File Specific Conversion Options

DynamicPDF Converter offers multiple conversion options depending on the file type being converted. The different option classes available are each discussed below for the following converters.

ConversionOptions

The ConversionOptions class is parent to the following classes:

Properties

The ConversionOptions class has the following properties:

Refer to the ConversionOptions API documentation for more details.

HtmlConversionOptions

The HtmlConversionOptions class specifies available settings for HTML to PDF conversion. Use this class with the HtmlConverter class or Converter.Convert static method which takes the options as a parameter.

The HtmlConversionOptions class as a Zoom property in addition to it's parent ConversionOptions class's properties.

HtmlConversionOptions htmlConversionOptions = new HtmlConversionOptions(480, 720, 36);
 
//Options with HtmlConverter class                     
HtmlConverter htmlConverter = new HtmlConverter(new Uri("http://www.dynamicpdf.com"),
  htmlConversionOptions);
htmlConverter.Convert(outPath);
                        
//OR
Converter.Convert(inPath, outPath, htmlConversionOptions);
Dim MyHtmlConversionOptions As HtmlConversionOptions = New HtmlConversionOptions(480,
  720, 36)
 
'Options with HtmlConverter class                      
Dim MyHtmlConverter As HtmlConverter = New HtmlConverter(New
  Uri("http://www.dynamicpdf.com"), MyHtmlConversionOptions)
MyHtmlConverter.Convert(outPath)
 
'Or
Converter.Convert(inPath, outPath, MyHtmlConversionOptions)

ImageConversionOptions & TiffConversionOptions

Use the ImageConversionOptions or TiffConversionOptions class for image conversion.

The ImageConversionOptions class is parent of the TiffConversionOptions class.

ImageConversionOptions

The ImageConversionOptions inherits the ConversionOptions class's properties and adds the ExpandToFit, ImageAlignment, ImageSizeAsPageSize, and ShrinkToFit properties.

The sample code below demonstrates using ImageConversionOptions.

ImageConversionOptions imageConversionOptions = new ImageConversionOptions(PageSize.A4,  
    PageOrientation.Landscape, 36);
 imageConversionOptions.ImageSizeAsPageSize = true;

 ImageConverter imageConverter = new ImageConverter(inPath, imageConversionOptions);
 imageConverter.Convert(outPath);
                        
 //OR image options can also be used with Converter.Convert static method
 Converter.Convert(inPath,outPath, imageConversionOptions);
 Dim MyImageConversionOptions As ImageConversionOptions = New ImageConversionOptions(PageSize.A4, PageOrientation.Landscape, 36)
 MyImageConversionOptions.ImageSizeAsPageSize = True

 Dim MyImageConverter As ImageConverter = New ImageConverter(inPath, MyImageConversionOptions)
 MyImageConverter.Convert(outPath)
                        
 'OR, image options can also be used with Converter.Convert static method
 Converter.Convert(inPath, outPath, MyImageConversionOptions)

TiffConversionOptions

The TiffConversionOptions are for Tiff images and inherits from the ImageConversionOptions class. The TiffConversionOptions class has the PageRange property, in addition to the properties inherited from ImageConversionOptions and ConversionOptions.

The following sample code demonstrates using TiffConversionOptions with the PageRange property.

 TiffConversionOptions tiffConversionOptions = new TiffConversionOptions(500, 500, 12);
 tiffConversionOptions.PageRange.StartPageNumber = 2;
 tiffConversionOptions.PageRange.EndPageNumber = 5;
 
 ImageConverter imageConverter = new ImageConverter(inPath, tiffConversionOptions);
 imageConverter.Convert(outPath);
                        
 //OR image options can also be used with Converter.Convert static method
 Converter.Convert(inPath, outPath, tiffConversionOptions);
 Dim MyTiffConversionOptions As TiffConversionOptions = New TiffConversionOptions(500, 500, 12)
 MyTiffConversionOptions.PageRange.StartPageNumber = 2
 MyTiffConversionOptions.PageRange.EndPageNumber = 5

 Dim MyImageConverter As ImageConverter = New ImageConverter(inPath, MyTiffConversionOptions)
 MyImageConverter.Convert(outPath)

 'OR, image options can also be used with Converter.Convert static method
 Converter.Convert(inPath, outPath, MyTiffConversionOptions)

RtfConversionOptions

The RtfConversionOptions class has a PageRange property in addition to the properties it inherits from ConversionOptions.

The following sample code demonstrates RTF to PDF conversion with options using the RtfConversionOptions class.

 RtfConversionOptions rtfConversionOptions = new RtfConversionOptions(PageSize.Letter, PageOrientation.Portrait, 36);
 rtfConversionOptions.Title = "RTF Document";

 RtfConverter rtfConverter = new RtfConverter(inPath, rtfConversionOptions);
 rtfConverter.Convert(outPath);
 
 //OR
 Converter.Convert(inPath, outPath, rtfConversionOptions);
 Dim MyRtfConversionOptions As RtfConversionOptions = New RtfConversionOptions(PageSize.Letter, PageOrientation.Portrait, 36)
 MyRtfConversionOptions.Title = "RTF Document"

 Dim RtfConverter As RtfConverter = New RtfConverter(inPath, MyRtfConversionOptions)
 RtfConverter.Convert(outPath)

 'Or
 Converter.Convert(inPath, outPath, MyRtfConversionOptions)

TextConversionOptions

The TextConversionOptions class has the PageRange and PrintPageNumbers properties in addition to the properties inherited from ConversionOptions.

The code below demonstrates Text to PDF Conversion with options using the TextConversionOptions class.

 TextConversionOptions textConversionOptions = new TextConversionOptions(PageSize.Legal, PageOrientation.Portrait, 72);
 
 TextConverter textConverter = new TextConverter(inPath, textConversionOptions);
 textConverter.Convert(outPath);
                        
 //OR
 Converter.Convert(inPath, outPath, textConversionOptions);
 Dim MyTextConversionOptions As TextConversionOptions = New TextConversionOptions(PageSize.Legal, PageOrientation.Portrait, 72)
 
 Dim TextConverter As TextConverter = New TextConverter(inPath, MyTextConversionOptions)
 TextConverter.Convert(outPath)

 'Or
 Converter.Convert(inPath, outPath, MyTextConversionOptions)

WordConversionOptions

The WordConversionOptions class has the OptimizeFor and PageRange properties in addition to the ConversionOptions class's properties.

The following code demonstrates Word to PDF Conversion with options using the WordConversionOptions class.

 WordConversionOptions wordConversionOptions = new WordConversionOptions(PageSize.Letter, PageOrientation.Portrait, 36);
 
 WordConverter wordConverter = new WordConverter(inPath, wordConversionOptions); 
 wordConverter.Convert(outPath);
                        
 //OR
 Converter.Convert(inPath, outPath, wordConversionOptions);
 Dim MyWordConversionOptions As WordConversionOptions = New WordConversionOptions(PageSize.Letter, PageOrientation.Portrait, 36)
 
 Dim WordConverter As WordConverter = New WordConverter(inPath, MyWordConversionOptions)
 WordConverter.Convert(outPath)
                        
 'Or
 Converter.Convert(inPath, outPath, MyWordConversionOptions)

PowerPointConversionOptions

The PowerPointConversionOptions class has the OutputType, PdfA, and PowerPointSlideRange properties in addition to the inherited ConversionOption class's properties.

ExcelConversionOptions

The ExcelConversionOptions class has the CoverSheets, Height, IgnorePrintAreas, Orientation, PageRange, PageScaling, PageSize, and Width properties in addition to the inherited ConversionOption class's properties.

For more information on the ExcelConversionOptions or the PowerPointConversionOptions, refer to the following topics (Excel to PDF, Power Point to PDF).

GitHub Project

Refer to the converter-dotnet-core example project on GitHub for examples using C# and Visual Basic. Each converter class has an example that also demonstrates using the class's conversion options.

C# Visual Basic
HtmlFileConversion.cs HtmlFileConversion.vb
JpegImageConversion.cs JpegImageConversion.vb
JpgImageConversion.cs JpgImageConversion.vb
GifImageConversion.cs GifImageConversion.vb
PngImageConversion.cs PngImageConversion.vb
TiffImageConversion.cs TiffImageConversion.vb
TextFileConversion.cs TextFileConversion.vb
DocFileConversion.cs DocFileConversion.vb

In this topic