Solved

How to set Custom MediaSizeName?

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Certificat to iSeries KeyStore 1 30
Maven Project: Hibernate Dependencies Conflict 10 93
JavaFX TableView not displaying correctly 3 161
java imports not found 4 71
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

738 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