Solved

How to set Custom MediaSizeName?

Posted on 2003-12-09
5
1,816 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 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

630 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