DynamicPDF™ Generator for .NET natively supports Multi-page Tiff documents and includes a method to quickly convert a multi-page Tiff document to PDF. Multi-page Tiffs are handled using the TiffFile class.

Accessing Pages from a Multi-page TIFF

TiffFile objects contain a collection of TiffImageData objects for each page in the document. These TiffImageData objects can be accessed by index and used in any Image or BackgroundImage constructor.

[Visual Basic]
' Create a TiffFile object from the TIFF image.
Dim MyTiffFile As TiffFile = New TiffFile( "C:\MyMultipageTiff.tif" )
' Add the first page as an image.
MyPage1.Elements.Add( New Image( MyTiffFile.Images(0), 0, 0 ) )
' Add the second page to the page as a background image.
MyPage2.Elements.Add( New BackgroundImage( MyTiffFile.Images(1) ) )

[C#]
// Create a TiffFile object from the TIFF image.
TiffFile tiffFile = new TiffFile( @"C:\MyMultipageTiff.tif" );
// Add the first page as an image.
page1.Elements.Add( new Image( tiffFile.Images[0], 0, 0 ) );
// Add the second page to the page as a background image.
page2.Elements.Add( new BackgroundImage( tiffFile.Images[1] ) );

Converting a Tiff to PDF

A Tiff can be converted to PDF with just three lines of code using the TiffFile objects GetDocument method:

[Visual Basic]
' Create a TiffFile object from the TIFF image.
Dim MyTiffFile As TiffFile = New TiffFile( "C:\MyMultipageTiff.tif" )
' Create a document object from the file.
Dim MyDocument As Document = MyTiffFile.GetDocument()
' Output the document to a file.
MyDocument.Draw( "C:\MyMultipagePDF.pdf" )

[C#]
// Create a TiffFile object from the TIFF image.
TiffFile tiffFile = new TiffFile( @"C:\MyMultipageTiff.tif" );
// Create a document object from the file.
Document document = tiffFile.GetDocument();
// Output the document to a file.
document.Draw( @"C:\MyMultipagePDF.pdf" );

See Also

TiffFile Class | Image Class | Images | Image Reuse | ceTe.DynamicPDF.Imaging Namespace | Programming With Generator for .NET | DynamicPDF.Generator Assembly