1

I want to print a bill in java using java PrintService. I am using FileOutputStream to create file. My Printer is tvs msp star 250 printer(dotmatrix). I tried "\f" and (char)12 to set a page break( form feed) character in file in doc,txt and rtf. But in each case my printer print bill and 1 more blank page.

My Source Code:

FileInputStream in = new FileInputStream(new File("c://brp.txt"));

PrintRequestAttributeSet  pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));


DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc doc = new SimpleDoc(in, flavor, null);

DocPrintJob job = service.createPrintJob();
PrintJobWatcher pjw = new PrintJobWatcher(job);
job.print(doc, pras);
pjw.waitForDone();
in.close();
InputStream ff = new ByteArrayInputStream("\f".getBytes());
Doc docff = new SimpleDoc(ff, flavor, null);
DocPrintJob jobff = service.createPrintJob();
pjw = new PrintJobWatcher(jobff);
jobff.print(docff, null);
pjw.waitForDone();
tshepang
  • 12,111
  • 21
  • 91
  • 136
JavaUser
  • 11
  • 1

0 Answers0