Java打印Dotmatrix打印机不停止送纸

时间:2013-11-12 04:01:02

标签: java printing dot-matrix

我想使用java PrintService在java中打印帐单。我正在使用FileOutputStream来创建文件。我的打印机是电视msp star 250打印机(dotmatrix)。我尝试了“\ f”和(char)12在doc,txt和rtf中的文件中设置分页符(换页)字符。但在每种情况下我的打印机打印帐单和另外1个空白页。

我的源代码:

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();

0 个答案:

没有答案