1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public void print(String docID) {
//String path = null;
try {
print(new FileInputStream(docID));
} catch(FileNotFoundException exception) {
exception.printStackTrace(); }
}
public void print(InputStream pTextStream) {
DocFlavor myFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc myDoc = new SimpleDoc(pTextStream, myFormat, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService services = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = services.createPrintJob();
try {
job.print(myDoc, aset);
}
catch(PrintException pe) {
pe.printStackTrace();
}
} |
Partager