Converting Images to PDFs

Converting images are straightforward using the DynamicPdf Converter for .NET.

ImageConverter

Convert images to PDFs using the ImageConverter class. This class supports converting the following image types.

DynamicPDF Converter does not support converting SVG images.

ImageConversionOptions options = new ImageConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50);
ImageConverter imageConverter = new ImageConverter(@"DocumentA.jpg", options);
imageConverter.Convert(outputPdf);
Dim options As ImageConversionOptions = New ImageConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50)
Dim imageConverter As ImageConverter = New ImageConverter("DocumentA.jpg", options)
imageConverter.Convert(outputPdf)

ImageConversionOptions

The ImageConversionOptions class can also take conversion options to specify how to format the created PDF. Conversion option properties include formatting the created PDF's dimensions, margins, and metadata.

This class inherits all of the ConversionOptions properties with the additional: ExpandToFit, ImageAlignment, ImageSizeAsPageSize, and ShrinkToFit properties.

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

ImageConversionOptions options = new ImageConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50);
ImageConverter imageConverter = new ImageConverter(@"DocumentA.png", options);
imageConverter.Convert(outputPdf);
Dim options As ImageConversionOptions = New ImageConversionOptions(PageSize.Legal, PageOrientation.Portrait, 50)
Dim imageConverter As ImageConverter = New ImageConverter("DocumentA.png", options)
imageConverter.Convert(outputPdf)

TiffConversionOptions

The TiffConversionOptions class inherits all of ConversionOptions and ImageConversionOptions properties with the additional PageRange property that allows specifying only certain pages from a multi-page TIFF.

The PageRange class has an EndPageNumber and a StartPageNumber property.

TiffConversionOptions options = new TiffConversionOptions(false);
options.PageRange.StartPageNumber = 3;
options.PageRange.EndPageNumber = 5;
ImageConverter converter = new ImageConverter(@"fw9_18.tif", options);
converter.Convert(outputdf);
Dim options As New TiffConversionOptions(False)
options.PageRange.StartPageNumber = 3
options.PageRange.EndPageNumber = 5
Dim converter As New ImageConverter("fw9_18.tif", options)
converter.Convert(Program.GetOutputDocPath(outputPdf))

In this topic