Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Facing problem in setting orientation.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have called this method for printing a .txt file.
I am creating a .txt file and then giving it to print.
By defaut the page orientation is portrait,but i want it in landscape.
so i had set the orientation.
but still i am getting it in portrait.what should i do?
need suggestion as early as possible...
below is mine part of code..

public void print(ArrayList arr) throws OMSApplicationException{
CustomerVO customerVO = null;
InputStream is = null;
try{
for(int i=0 ; i<arr.size();i++)
{
customerVO = (CustomerVO) arr.get(i);
File file = new File("D:\\PinGeneration.txt");
boolean success = file.createNewFile();
if (success) {
System.out.println("new file");
createFile1(customerVO);// if file is not there
} else// if file already there
{
boolean success1 = new File("D:\\PinGeneration.txt").delete();
if (!success1) {
System.out.println("file deletion problem!!!");
} else {
System.out.println("file alredy exit!!!");
createFile1(customerVO);// again create the file
}
}
is = new BufferedInputStream(new FileInputStream("D:\\PinGeneration.txt"));
System.out.println("Value of textStream : " + is);
DocFlavor myFormat = DocFlavor.INPUT_STREAM.AUTOSENSE; // Create a Doc
Doc myDoc = new SimpleDoc(is, myFormat, null));
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(OrientationRequested.LANDSCAPE);
aset.add(new Copies(1));
aset.add(Sides.ONE_SIDED);
System.out.println("Value of textStream : ");
AttributeSet aset1 = new HashAttributeSet();
aset1.add(new PrinterName("Kyocera Mita FS-9500DN KX", null));
aset1.add(SUPPORTED);
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, aset1);
if (services.length > 0) {
DocPrintJob job = services[0].createPrintJob();
try {
System.out.println(services[0]);
job.print(myDoc, aset);
} catch (PrintException pe) {
pe.printStackTrace();
}
}
}}catch(Exception e){}}


Thanks
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic