I have a dot matrix printer nad i want to print data directly to the dot matrix
printer. I have use the JasperReport as reporting tool but it prints very
slowly. I have also use the JRTextExporter exporter = new JRTextExporter(); for
exporting reports in text but it can't make a good alignment to the text and
event i can't do any type of formatting in the text File. My Code is
[b]public void convertToText[/b]() {
JRTextExporter exporter = new JRTextExporter();
File file = new File("C:\\bill.html");
try {
exporter.setParameter(JRTextExporterParameter.JASPER_PRINT,report.getReport());
exporter.setParameter(JRTextExporterParameter.OUTPUT_FILE, file);
exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT,new
Integer(15));
exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH,new
Integer(22));
exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH,new
Integer(30));
exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT,new
Integer(30));
exporter.exportReport();
getPrinter(file);
} catch (Exception ex) {
ex.printStackTrace();
}
}
[b]public void getPrinter[/b](File file)
throws PrintException, FileNotFoundException {
javax.print.DocFlavor flavor =
javax.print.DocFlavor.INPUT_STREAM.AUTOSENSE;
javax.print.attribute.PrintRequestAttributeSet pras =
new javax.print.attribute.HashPrintRequestAttributeSet();
PrintService printService =
PrintServiceLookup.lookupDefaultPrintService();
javax.print.DocPrintJob job = printService.createPrintJob();
java.io.FileInputStream fis = new java.io.FileInputStream(file);
javax.print.attribute.DocAttributeSet das = new
javax.print.attribute.HashDocAttributeSet();
javax.print.Doc doc = new javax.print.SimpleDoc(fis, flavor, das);
job.print(doc, pras);
}
}
[Message sent by forum member 'aroop_bh' (aroop_bh)]
http://forums.java.net/jive/thread.jspa?messageID=227537
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".