Solved

Print to LPT1

Posted on 2002-07-16
4
1,081 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

688 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