• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JAVA Printing Help

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nagaraj Pattar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Nagaraj Pattar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic