By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

Printing seems way too hard...

P: n/a
Is there an easy way to send a "Hello World" to the printer???
-- Dave
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Dave D" <dd@ddnet.com> tried to express:
Is there an easy way to send a "Hello World" to the printer???


echo "Hello World" | lpr
Jul 17 '05 #2

P: n/a
I mean using Java!

-- Dave

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
"Dave D" <dd@ddnet.com> tried to express:
Is there an easy way to send a "Hello World" to the printer???


echo "Hello World" | lpr

Jul 17 '05 #3

P: n/a

"Dave D" <dd@ddnet.com> wrote in message
news:p2a3c.214730$uV3.826726@attbi_s51...
I mean using Java!

-- Dave

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
"Dave D" <dd@ddnet.com> tried to express:
Is there an easy way to send a "Hello World" to the printer???


echo "Hello World" | lpr



Dave,

Printers are controlled as graphical devices which means that simply
printing a piece of text has no direct support. It is very easy to get the
stuff you paint on a graphical component on a printer, but is is also not
trivial to print "hello world" on a graphical component.

Silvio Bierman
Jul 17 '05 #4

P: n/a
Runtime.getRuntime().exec("bash -c \"echo 'Hello World' | lpr\"");

;)

"Dave D" <dd@ddnet.com> wrote in message
news:p2a3c.214730$uV3.826726@attbi_s51...
I mean using Java!

-- Dave

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
"Dave D" <dd@ddnet.com> tried to express:
Is there an easy way to send a "Hello World" to the printer???


echo "Hello World" | lpr


Jul 17 '05 #5

P: n/a
I think Java's printing API pretty much sucks, too. If you're using
version 1.4.1 or above, you can use the PrintService class, which
makes printing certain types of documents easier:

http://java.sun.com/j2se/1.4.2/docs/...ntService.html

Most of the document types had not been implemented the last time I
looked at it, though.

If this doesn't work for you (which didn't in my case), you have to
manually pagenate your content and then draw it on a graphics pane:

http://java.sun.com/docs/books/tutorial/2d/printing/

Good luck.

-Nathan

"Dave D" <dd@ddnet.com> wrote in message news:<p2a3c.214730$uV3.826726@attbi_s51>...
I mean using Java!

-- Dave

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
"Dave D" <dd@ddnet.com> tried to express:
Is there an easy way to send a "Hello World" to the printer???


echo "Hello World" | lpr

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.