aspose file tools*
The moose likes Java in General and the fly likes Printing data using Java in Linux/Unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Printing data using Java in Linux/Unix" Watch "Printing data using Java in Linux/Unix" New topic
Author

Printing data using Java in Linux/Unix

karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 115

Hi guys,
I have a requirement where i need to call the printer API directly via my Java code and print. I have some specific alignment for my data. My code is as follows..


When i run this class in Eclipse , it works fine. But when i run this application in Unix environment , it is not printing the data. Instead it prints some characters like some ip adresses and some font names. Have analysed and found it to because of the format with which the data gets printed. It prints in a RAW format. I need to print my data alike. Please help me. Either i need to change this format to TEXT or use CUPS to configure. Please guide me how can i set the dataType to TEXT in Java so that it will print the data correctly.


"Learning is a Culture where your Eagerness & Curiosity plays a major Role".
karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 115

Could someone help me out in resolving this. It's very urgent.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

karthik Suryanarayanan wrote:
When i run this class in Eclipse , it works fine. But when i run this application in Unix environment , it is not printing the data.



You have to give us more detail than that. Is it going to the same printer? Is it on the same machine? If not, using the same operating system?

If the only difference is it works from eclipse and not from the command line, then you just have to ensure that the command line is using the same jar and class files (and libraries) as the eclipse environment.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

Please EaseUp. There is no such thing as "urgent" around here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 115


There is no issue from calling JAVA AWT API to printer in windows machine.

Printer is connected to Unix server and we are able print the files properly using the lpr filename command in unix server but in Unix server when we call to printer from java AWT API from application it is printing the junk characters and some setting relating informations are being printed on the papers.
karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 115

And regarding encoding , i got the following ones in my unix server.

Unix

System.getProperty("file.encoding") - 8859_1

Charset.defaultCharset() - ISO-8859-1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing data using Java in Linux/Unix