Solved

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

Posted on 2008-06-12
7
728 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
ID: 21774252
How are you printing it? Maybe you just need to scale to fit

0
 

Author Comment

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

Regards,

Vivek V. Sapre
0
 

Author Comment

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

Regards,

Vivek V. Sapre
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

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

0
 

Author Comment

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

Regards,
Vivek V. Sapre
0
 
LVL 9

Accepted Solution

by:
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.
0
 

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 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

11 Experts available now in Live!

Get 1:1 Help Now