Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set Custom MediaSizeName?

Posted on 2003-12-09
5
Medium Priority
?
1,861 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
[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
  • 3
5 Comments
 
LVL 4

Accepted Solution

by:
tapasvi earned 140 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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