Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 29th, 2004, 10:50 PM
Ermintrude Ermintrude is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 Ermintrude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help in printing with java

I want to print an image from my harddisk and I need to print it at a specific location and size. How do I do it?

I am using the new javax.print package but after some failures, I tried to include some of the old java.awt.print code. I still get errors. Please help.

Here's the code:

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
aset.add(OrientationRequested.PORTRAIT);
aset.add(new Copies(1));
PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
//This is the code from the old awt.print package
Paper paper = new Paper();
PageFormat page = new PageFormat();
paper.setImageableArea(0,0,600,800);
page.setPaper(paper);
//Using the new DocPrintJob and old setPrintable, I tried to
//print at the desired size and position
DocPrintJob printJob = pservices[0].createPrintJob();
#printJob.setPrintable(this, page);

I still get 2 errors on the # line:
1) Can't refer a non-static var.(this) from a static context
2) Can't resolve symbol(setPrintable)

Can anyone help me solve this and be able to print on any location and any desired size using the javax.print package? Thanks in advance.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Help in printing with java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway