Solved

How to set Custom MediaSizeName?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

740 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