?
Solved

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

Posted on 2008-06-12
7
Medium Priority
?
735 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
[X]
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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1500 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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