• Post Reply Bookmark Topic Watch Topic
  • New Topic

Facing problem in setting orientation.  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!