TiffFile Class | Image Class |  Images | com.cete.dynamicpdf.imaging Package | Programming With Generator for Java

Welcome > Generator > Programming > Images > Tiff Images

DynamicPDF™ Generator for Java 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.

[Java]
    // Create a TiffFile object from the TIFF image.
    TiffFile tiffFile = new TiffFile("[PhysicalPath]/MyMultipageTiff.tif");
    // Add the first page as an image.
    page1.getElements().add(new Image(tiffFile.getImages().getTiffImageData(0), 0, 0, 0.24f));
    // Add the second page to the page as a background image.
    page2.getElements().add(new BackgroundImage(tiffFile.getImages().getTiffImageData(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:

[Java]
    // Create a TiffFile object from the TIFF image.
    TiffFile tiffFile = new TiffFile("[PhysicalPath]/MyMultipageTiff.tif");
    // Create a document object from the file.
    Document document = tiffFile.getDocument();
    // Output the document to a file.
    document.draw("[PhysicalPath]/MyMultipagePDF.pdf");

See Also 

TiffFile Class | Image Class |  Images | com.cete.dynamicpdf.imaging Package | Programming With Generator for Java