Convert TIFF to PDF
JDeli is able to convert TIFF to PDF image files.
JDeli can do this in ONE step with the convert method. You can also do this by reading a TIFF image and then writing the image as PDF, which is useful if you want to process the image in some way.
Convert any images to PDF from Command Line or another language
java -jar jdeli.jar --convert pdf "inputFileOrDir" "outputDir"
Single step method to convert from TIFF into a PDF image file in Java
JDeli.convert(File inFile, File outFile);
JDeli.convert(InputStream inFile, OutputStream outfile, String format);
byte[] outputData = JDeli.convert(byte[] inputData, String format);
Depending on the image formats being converted (ie different image compression options), JDeli also provides overloaded methods. These can be used to supply conversion options for more control over the conversion process.
Read / Write methods for converting from TIFF into a PDF image file in Java
- Read TIFF image into Java
BufferedImage image = JDeli.read(tiffImageFile);
or
TiffDecoder decoder = new TiffDecoder(); BufferedImage image = decoder.read(tiffData);
-
Process image
- Write out Java image as PDF
File pdfImageFile = new File("Image.pdf"); JDeli.write(image, "pdf", pdfImageFile);
or:
PdfEncoder encoder = new PdfEncoder(); encoder.write(image, outputStream);
How to convert from multi TIFF into PDF file
There are several ways you can convert a multi TIFF to a PDF file:
- If you are looking to convert a multi-TIFF file to a PDF file you can use the JDeli.convert(inFile, outFile) methods for this as they will handle everything for you.
- For any other conversions you can use the example below:
TiffDecoder decoder = new TiffDecoder();
PdfEncoder encoder = new PdfEncoder();
int imageCount = decoder.getImageCount(inFile);
for (int i = 0; i < imageCount; i++) {
BufferedImage image = decoder.readImageAt(i, inFile);
//write out the PDF
encoder.write(image, outputStreamorFile);
}