Skip to main content

File Specific Converters

Version: 3.0

File Specific Converters and Conversion Options

DynamicPDF Converter offers multiple converters and conversion options depending upon the file type.

Converter Child Classes​

The following are child classes of the Converter parent class.

Each has file-type specific methods and properties. Refer to the following pages for more information on each file-specific converter.

tip

For most processing needs you can use the static Converter.Convert method rather than one of the specific converters.

ConversionOptions​

Use either the ConversionOptions parent class or one of the file specific conversion option child classes depending on the file type being converted. The ConversionOptions class is parent to the following classes:

Each file specific options class adds several file specific properties depending upon the file type it handles.

tip

You can also any of the conversion options subclasses with the Converter.Convert method.

ExcelConversionOptions​

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

info

For more information on ExcelConverter and ExcelConversionOptions refer to the Converting Excel Spreadsheets to PDFs documentation.

ExcelConversionOptions options = new ExcelConversionOptions(false);
ExcelConverter excelConverter = new ExcelConverter(@"DocumentA.xlsx", options);
excelConverter.Convert(outputPdf);
Dim options As New ExcelConversionOptions(False)
Dim excelConverter As New ExcelConverter("DocumentA.xlsx", options)
excelConverter.Convert(outputPdf)

[ExcelFileConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/ExcelFileConversion.cs){#gitlink-id target=_blank}


[ExcelFileConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/ExcelFileConversion.vb){#gitlink-id target=_blank}

HtmlConversionOptions​

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

info

For more information on HtmlConverter and HtmlConversionOptions refer to the Converting HTML to PDFs documentation.

HtmlConversionOptions htmlConversionOptions = new HtmlConversionOptions(480, 720, 36);
HtmlConverter htmlConverter = new HtmlConverter(new Uri("http://www.dynamicpdf.com"),
htmlConversionOptions);
htmlConverter.Convert(outPath);
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)

[HtmlConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/HtmlConversion.cs){#gitlink-id target=_blank}


[HtmlConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/HtmlConversion.vb){#gitlink-id target=_blank}

ImageConversionOptions & TiffConversionOptions​

Use the ImageConversionOptions or TiffConversionOptions class for image conversion.

info

For more information on ImageConverter and ImageConversionOptions refer to the Converting Images to PDFs documentation.

ImageConversionOptions​

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

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

ImageConverter imageConverter = new ImageConverter(inPath, imageConversionOptions);
imageConverter.Convert(outPath);
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)

[JpgImageConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/JpgImageConversion.cs){#gitlink-id target=_blank}


[JpgImageConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/JpgImageConversion.vb){#gitlink-id target=_blank}

TiffConversionOptions​

The TiffConversionOptions are for Tiff images and inherits from the ImageConversionOptions class but also adds the additional 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);
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)

[TiffImageConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/TiffImageConversion.cs){#gitlink-id target=_blank}


[TiffImageConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/TiffImageConversion.vb){#gitlink-id target=_blank}

RtfConversionOptions​

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

info

For more information on RtfConverter and RtfConversionOptions refer to the Converting Text and RTF to PDFs documentation.

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

RtfConverter rtfConverter = new RtfConverter(inPath, rtfConversionOptions);
rtfConverter.Convert(outPath);
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)

[TextRtfConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/TextRtfConversion.cs){#gitlink-id target=_blank}


[TextRtfConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/TextRtfConversion.vb){#gitlink-id target=_blank}

TextConversionOptions​

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

info

For more information on TextConverter and TextConversionOptions refer to the Converting Text and RTF to PDFs documentation.

TextConversionOptions textConversionOptions = new TextConversionOptions(PageSize.Legal, PageOrientation.Portrait, 72);

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

Dim TextConverter As TextConverter = New TextConverter(inPath, MyTextConversionOptions)
TextConverter.Convert(outPath)

[TextRtfConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/TextRtfConversion.cs){#gitlink-id target=_blank}


[TextRtfConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/TextRtfConversion.vb){#gitlink-id target=_blank}

WordConversionOptions​

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

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

info

For more information on WordConverter and WordConversionOptions refer to the Converting Word Documents to PDFs documentation.

WordConversionOptions wordConversionOptions = new WordConversionOptions(PageSize.Letter, PageOrientation.Portrait, 36);

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

Dim WordConverter As WordConverter = New WordConverter(inPath, MyWordConversionOptions)
WordConverter.Convert(outPath)

[WordFileConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/WordFileConversion.cs){#gitlink-id target=_blank}


[WordFileConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/WordFileConversion.vb){#gitlink-id target=_blank}

PowerPointConversionOptions​

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

info

For more information on PowerPointConverter and PowerPointConversionOptions refer to the Converting PowerPoint Presentations to PDFs documentation.

PowerPointConversionOptions options = new PowerPointConversionOptions(false);

PowerPointConverter pptConverter = new PowerPointConverter(@"DocumentA.pptx", options);
pptConverter.Convert(outputPdf);
Dim options As PowerPointConversionOptions = New PowerPointConversionOptions(False)
Dim powerPointConverter As PowerPointConverter = New PowerPointConverter("DocumentA.pptx", options)
powerpointConverter.Convert(outputPdf)

[PptFileConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/PptFileConversion.cs){#gitlink-id target=_blank}


[PptFileConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/PptFileConversion.vb){#gitlink-id target=_blank}

AppendToPdf​

The ConversionOptions class has an AppendToPdf property. This property allows appending to an existing PDF document. The following example illustrates using this property with the HtmlConversionOptions child class.

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

string html = "<html><body><p>Very simple HTML."
+ "</p></body></html>";

HtmlConverter converter = new(new Uri("http://www.google.com"));
converter.Convert(outputPdf);

HtmlConversionOptions options = new(PageSize.A4, PageOrientation.Landscape, 36);

options.AppendToPdf = true;
HtmlConverter converterB = new(html, options);
converterB.Convert(outputPdf);
Dim html As String = "<html><body><p>Very simple HTML." &
"</p></body></html>"

Dim converter As New HtmlConverter(New Uri("http://www.google.com"))
converter.Convert(Program.GetOutputDocPath(outputPdf))

Dim options As New HtmlConversionOptions(PageSize.A4, PageOrientation.Landscape, 36)
options.AppendToPdf = True
Dim converterB As New HtmlConverter(html, options)
converterB.Convert(outputPdf)

[HtmlConversion.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/HtmlConversion.cs){#gitlink-id target=_blank}


[HtmlConversion.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/HtmlConversion.vb){#gitlink-id target=_blank}

Figure 1. Appending to a PDF document