Solved

Print to LPT1

Posted on 2002-07-16
4
1,038 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now