Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How can I convert .tif files to PDF using Java?

Posted on 2008-06-12
Last Modified: 2013-11-23

 I have got several .tif files which are present on a unix server. If I try to print them using a lp command  in unix , a single page gets split into 2-4 pages. However, if the file is a pdf file then the printer seems to print it fine.

 Can someone please give some pointers on how we can convert .tif files to .pdf using java?

Note: we have java 1.4.x
Question by:viveksapre
  • 4
  • 2
LVL 92

Expert Comment

ID: 21774252
How are you printing it? Maybe you just need to scale to fit


Author Comment

ID: 21774481
I am using the unix command 'lp' to print the files.

  Even if i do a 'fitplot' it still is splitting the file in 4 parts and printing it. If however, I ftp the file on to my local machine and print it through Windows its prints the image on one page, without any issues. I compared the size of the text when printed through unix (i.e. in 4 pages ) vs the image file when printed through windows (1 page) and it is exactly the same
I guess, windows doesn't seem to be shrinking it but is still able to print it on one page.
These images are scanned invoice images , so the actual paper invoice is of either letter or A4 size.


Vivek V. Sapre

Author Comment

ID: 21774539
I also tried doing scaling, reducing margins on all 4 sides to 0 when printing using lp but still no difference. On the other hand if I go to some website and convert the file to a .pdf and then try printing using lp it prints it perfectly on one page.
So it seems to be something related to the .tif file format and the printer being able to understand it.


Vivek V. Sapre
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 92

Expert Comment

ID: 21775564
how can the text be the same size and span 4 pages?

Sounds like it may be a resolution/dpi issue

theres nothing special about a tif file, its just an image.


Author Comment

ID: 21776012
I actually placed one of the 1/4 image pages over the full one (that I printed from windows) and found that every letter and figure exactly match.

 I agree that the .tiff file is just an image but the printer is splitting the top left half on one page, the top right half on one page, the bottom left half on one page , and the bottom right half on one page. If you club together all the 4 parts (i.e. the printed portions) and compare it with the single page copy (which I printed through windows) they are exact replicas.

 It has something to do with the way the tif file is created. there is a scanner that scans the images and it gets stored on the server. If I manually generate a tif file on my local machine, ftp it to the server and print it using lp it prints fine. No Splitting takes place. However the ones that the scanner generates have some kind of compression also applied to it and that seems to be the only difference. I am sure it is something to do with the tiff image, so if I can convert it to a pdf and then print, then I won't have any issue.

Vivek V. Sapre

Accepted Solution

mbodewes earned 500 total points
ID: 21777593
Sorry if I am questioning the question here, but is there a specific reason that you want to use Java for this? Why not just use a batch image conversion utility and call it from Java? There should be at least one capable of putting an image into a PDF document?

That said, with a combination of the imageio Java classes and the iText libraries would be sufficient to providde this functionality. Both are compatible with JDK 1.4 it seems.

Author Comment

ID: 21862771
I developed code using iText and jai libraries and it has resolved my issue.

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
nextBoolean(double p) for Random class 3 41
Java exception bubble up 2 21
Java: How do I open the default windows program for a given file type 3 39
jsp error 6 25
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question