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