Solved

How to set Custom MediaSizeName?

Posted on 2003-12-09
5
1,648 Views
Last Modified: 2012-05-04
Hi Experts,
  I liked to know how to set a custome MediaSizeName, for taking the print of a bill.  Now I am using  MediaSizeName.ISO_A4, instead of that the paper I am going to use is of size 100mm x 150mm size.  

Now I am using :

DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(OrientationRequested.PORTRAIT);
pras.add(MediaSizeName.ISO_A4);
pras.add(new Copies(1));
pras.add(new JobName("My job", null));
PrintService printServices[] = PrintServiceLookup.lookupPrintServices(flavor, pras);

Regards
Suresh
0
Comment
Question by:sureshbvs
  • 3
5 Comments
 
LVL 4

Accepted Solution

by:
tapasvi earned 35 total points
ID: 9940974
Hi buddy:

you can use javax.print.attribute.standard.MediaPrintableArea class..
any of the two constructors.

MediaPrintableArea(float x, float y, float w, float h, int units)
          Constructs a MediaPrintableArea object from floating point values.

MediaPrintableArea(int x, int y, int w, int h, int units)
          Constructs a MediaPrintableArea object from integer values.

This way, you can use any size paper(iso A4 or any) but still specify the printable area on the paper.

Api below will help you further:

http://java.sun.com/j2se/1.4.2/docs/api/javax/print/attribute/standard/MediaPrintableArea.html

So what you can do is ...set width and height as 100mm and 150mm in MediaPrintableArea class.

Tapasvi


0
 
LVL 4

Expert Comment

by:tapasvi
ID: 11665284
Pls. Accept the Answer posted by tapasvi. ;-)
taps

0
 
LVL 4

Expert Comment

by:tapasvi
ID: 11665288
Pls. Accept the Answer posted by tapasvi. ;-)
taps
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countAbc challenge 9 50
countHi2 challenge 7 44
strCopies  challenge 17 74
Starting to learn JAVA, 7 48
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

743 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

11 Experts available now in Live!

Get 1:1 Help Now