Solved

Print to LPT1

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 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

16 Experts available now in Live!

Get 1:1 Help Now