Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-12
7
Medium Priority
?
737 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

604 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