I am looking for a good tutorial with examples for printing using Java. The best article I have found on Line is "Printing in Java" by JavaWorld. However, the links to download the example programs seem to be long defunct. Any suggestions?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I am looking for a good tutorial with examples for printing using Java. The best article I have found on Line is "Printing in Java" by JavaWorld. However, the links to download the example programs seem to be long defunct. Any suggestions?
Have you read the tutorials from the 'source' (aka Oracle)?
Lesson: Printing (The Java™ Tutorials > 2D Graphics)
Yes, I have read the tutorials - but they are very shy on examples. They also tend to brush over details like setting the page orientation and changing fonts. Also page headers and footers seem to be minimally covered.
It might be feasible to get a good Java Book - there are lots available though, so
finding the exact one for the problem could be an uphill task. Check out "effective Java"
or "Java How to Program" - those are well known books - also, Bruce Eckel has released
his third Java electronic booklet for free usage. He is quite renowned for producing
excellent text for subjects of C, C++ and Java - probably one of the best sources.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
I just had this issue also, make a PrinterJob object and call the print() method. You then have to have your own print method, public int print(Graphics g, PageFormat pf, int page).
The page variable is misleading because this method is called with the same page number multiple times.
As far as fonts, look up the Graphics class and the Graphics2D class,