PDF to TIFF - pqScan.com
Java PDF to TIF/TIFF Converting PDF Pages into TIFF Image Files in Java Download Trial Purchase Now

How to Convert PDF to TIFF in Java?

back to home  >  Java PDF to Image SDK  >  How to Convert PDF to Image in Java  >  Convert PDF to TIFF

Getting TIF image from PDF pages is a key feature in pqScan Java PDF to Image SDK. Java PDF to Image converter library is completely developed in Java SDK 1.6, and customers can easily integrate the transforming PDF pages to tiff function in their Java application.

In this article, we will introduce you how to convert PDF to single page tiff images. And we provide another article for converting PDF to a multiple pages tiff image, if you have interested in, you can view that.

Install Java PDF to Image Converter to your Java application

  • Copy pqScan.PDFtoImage.jar to your Java project library folder.
  • Add pqScan.PDFtoImage.jar to your Java classpath.

Java PDF to TIFF APIs

Before your conversion, there are some useful properties and methods supported.

//load the local PDF document
public void loadPDF(String fileName);
//load PDF stream
public void loadPDF(InputStream stream);
//get total PDF page information
public int getPageCount();
//changing output tiff image quality and definition by setting image resolution
public void setDPI(int dpi);

There are two methods to transform PDF to single page tiff image. One is getting tiff image from PDF page with original size, the other is getting tiff image from PDF page with customized size.

//turning PDF page to a single page tiff image in default page size
public BufferedImage toImage(int pageIndex);
// turning PDF page to a single page tiff image in specify size
public BufferedImage toImage(int pageIndex, int width, int height);

Converting PDF Pages to Single Page TIFF in Java class

Following Java code shows how to turn PDF to single page TIFF images. As you see, here we used JAI library to generate and render TIFF image from PDF.

import com.pqscan.pdftoimage.PDFDocument;
import com.sun.media.jai.codec.TIFFEncodeParam;
import com.sun.media.jai.codecimpl.TIFFImageEncoder;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.OutputStream;

public class PDFtoTIFFConverter {

   public static void main(String[] args)
   {
       try
       {
           //load PDF in memory
           PDFDocument doc = new PDFDocument();
           doc.loadPDF("f:/Sample.pdf");
           int pageCount = doc.getPageCount();

           for(int i = 0; i < pageCount; i++)
           {
               //convert each PDF page to image
               BufferedImage image = doc.toImage(i);
               //save image as tiff format
               OutputStream out = new FileOutputStream("output"+i+".tiff");
               TIFFEncodeParam param = new TIFFEncodeParam();
               param.setCompression(TIFFEncodeParam.COMPRESSION_DEFLATE);
               TIFFImageEncoder encoder = new TIFFImageEncoder(out, param);
               encoder.encode(image);
               out.close();              
           }
       }
       catch (Exception e) {
               e.printStackTrace();
       }
   }
}

convert pdf page to single page tif image in java

PDF to Image Convert to JPEG in Java Convert to PNG in Java Convert to BMP in Java Convert to GIF in Java Convert to Multi-TIFF in Java