*
The moose likes Java in General and the fly likes JAVA Printing Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JAVA Printing Help" Watch "JAVA Printing Help" New topic
Author

JAVA Printing Help

Nagaraj Pattar
Greenhorn

Joined: Sep 29, 2011
Posts: 3
Can anybody share your java expertise with me.. ??

I have a java program which uses PrintService API to create a PrintJob for printing text content. I am trying to make this program to have a typewriter effect.

Confused, Let me explain, As soon as you type a key, it should appear on the page @ the printer. The next letter should appear next to the previous letter and so on. There should not be any buffering, for eg., read an entire line and then print it on the paper.

I have tried my best but the problem is: As soon as type next letter, the printer (Print Service ) resets the printer page. The printer then Prints the next letter in the next page.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Welcome to the Ranch.

I must admit I don't know much about the Java printing API, but I think that what you want is not really possible.

What kind of printer are you using? If it's an inkjet printer or a laser printer, then it's most likely not going to work. These printers do not print a letter each time when the computer sends one character to the printer. Rather, the computer sends the information for a whole page to the printer, which the printer then processes and prints. I doubt that it is possible to print letter by letter on such printers.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Nagaraj Pattar
Greenhorn

Joined: Sep 29, 2011
Posts: 3
Its similar to a dot matrix printer where you have infinite length paper source.


My other requirement is little bit different:

Okay, Assume that the program is sending data to the printer page by page.. Everytime you request for printing the printer repositions the page by moving the page inward / outward.

Is it possible to avoid ? The printer should start printing the next page assuming that the page positioning is already done / manually done..

??? Please help
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

Try writing to LPT1
If I remember correctly that is the default parallel printer port (at least on windoze) and you can open a "stream" to it, treating it just like any other file.

Disclaimer: Things might have changed over the years. Way back around 2003, I had designed a hardware which would accept characters at runtime and the hardware would convert them to Braille. This hardware was attached to the LPT1 port and I remember having code which would communicate to the port using FileWriter. This was using java 1.2


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Nagaraj Pattar
Greenhorn

Joined: Sep 29, 2011
Posts: 3
Hi Maneesh,

thanks for your reply, I have tried that as well. nothing is in my favor.. The printer still writes the new character in a new page.



is my code, where ArrayList contains a list of String objects. This code constructs a temporary file and then the file is given as input to the printer job.

once the file is printed on to the printer, next call to the same method, readjusts the paper by pulling inside before printing..

I want to avoid the readjusting of the paper.. I would like the printer to continue to print from the same position without pulling the paper inside..

Any attributes we have to pass to the print service api ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

In future, while posting code, please UseCodeTags. I have edited your original post this time. As you can see the code tags make the code much more easier to read and understand.

I have tried that as well. nothing is in my favor.. The printer still writes the new character in a new page.

Which part of the code you posted tries to print to LPT1?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAVA Printing Help
 
Similar Threads
JeditorPane End of Page character
printing from an applet toolbar the image displayed in the applet via a thread
Printing - AWT/Swing & A4 Paper - RESOLVED
Printing issue
is there any guide lines for this problem ?