Solved

Print to LPT1

Posted on 2002-07-16
4
1,065 Views
Last Modified: 2008-03-17
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
Comment
Question by:eesrinivaassan
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 7157458
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
 
LVL 9

Assisted Solution

by:yongsing
yongsing earned 50 total points
ID: 7158465
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
 
LVL 1

Expert Comment

by:Computer101
ID: 7158482
I have deleted the 2 duplicate questions.  The only comments were that of yongsing

Computer101
E-E Moderator
0
 
LVL 35

Expert Comment

by:girionis
ID: 8917466
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet web applications   metadata-complete="true" or false 3 188
ejb on wildfly 5 45
ejb mdb examples 1 19
Java List 4 32
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question