• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • Last Modified:

Print to LPT1

Dear Experts,

I have some text in TextArea object.
How can I send it directly to LPT1
with out proving any print setup options.

If you are pressing a Button,
this event should sent the contents
to printer. (Dot Matrix)

I Want DOS-Text print format,
not in RichText format.

Help me

srin
0
eesrinivaassan
Asked:
eesrinivaassan
2 Solutions
 
CEHJCommented:
If you do a find on 'no dialog' on this page, you should be able to adapt the code:

http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/render.html
0
 
yongsingCommented:
Simply treat the LPT1 as though it is a normal file, and write the text to this file:

// Get the content of the text area
byte[] bytes = textArea.getText().getBytes();

try {
  FileOutputStream outputStream = new FileOutputStream("LPT1");
  outputStream.write(bytes);
  outputStream.close();
} catch (FileNotFoundException fileNotFoundException) {
  fileNotFoundException.printStackTrace();
  System.out.println("Error communicating with the printer.");
} catch (IOException ioException) {
  ioException.printStackTrace();
  System.out.println("Error printing on the printer.";
}
0
 
Computer101Commented:
I have deleted the 2 duplicate questions.  The only comments were that of yongsing

Computer101
E-E Moderator
0
 
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- split points between CEHJ and yongsing

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now