Solved

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

Posted on 2008-06-12
7
727 Views
Last Modified: 2013-11-23
Hi,

 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
0
Comment
Question by:viveksapre
  • 4
  • 2
7 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
How are you printing it? Maybe you just need to scale to fit

0
 

Author Comment

by:viveksapre
Comment Utility
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.

Regards,

Vivek V. Sapre
0
 

Author Comment

by:viveksapre
Comment Utility
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.

Regards,

Vivek V. Sapre
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 92

Expert Comment

by:objects
Comment Utility
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.

0
 

Author Comment

by:viveksapre
Comment Utility
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.

Regards,
Vivek V. Sapre
0
 
LVL 9

Accepted Solution

by:
mbodewes earned 500 total points
Comment Utility
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.
0
 

Author Comment

by:viveksapre
Comment Utility
I developed code using iText and jai libraries and it has resolved my issue.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now