Reader rdr;
try {
flavor = DocFlavor.URL.PDF;//TEXT_HTML_HOST;
if (serv.isDocFlavorSupported(flavor)) {
aset.add(new JobName(flavor.toString(), Locale.US));
dset.add(new DocumentName(http_ps, Locale.US));
job = serv.createPrintJob();
url = new URL(http_ps);
doc = new SimpleDoc(url, flavor, dset);
System.out.println("\nPrinting on "
+ job.getPrintService().getName() + "...");
job.print(doc, aset);
System.out.println("File '" + http_ps + "' was printed as "
+ flavor.getRepresentationClassName());
}
flavor = DocFlavor.URL.GIF;
if (serv.isDocFlavorSupported(flavor)) {
aset.add(new JobName(flavor.toString(), Locale.US));
dset.add(new DocumentName(http_gif, Locale.US));
job = serv.createPrintJob();
url = new URL(http_gif);
doc = new SimpleDoc(url, flavor, dset);
System.out.println("\nPrinting on "
+ job.getPrintService().getName() + "...");
job.print(doc, aset);
System.out.println("File '" + http_gif + "' was printed as "
+ flavor.getRepresentationClassName());
}
} catch (PrintException e1) {
e1.printStackTrace();
}
flavor = DocFlavor.READER.TEXT_PLAIN;
if (serv.isDocFlavorSupported(flavor)) {
aset.add(new JobName(flavor.toString(), Locale.US));
dset.add(new DocumentName(file_txt, Locale.US));
job = serv.createPrintJob();
rdr = new InputStreamReader(getClass().getResourceAsStream(
file_txt));
doc = new SimpleDoc(rdr, flavor, dset);
System.out.println("Printing on "
+ job.getPrintService().getName() + "...");
job.print(doc, aset);
System.out.println("File '" + file_txt + "' was printed as "
+ flavor.getRepresentationClassName());
}
flavor = DocFlavor.INPUT_STREAM.GIF;
if (serv.isDocFlavorSupported(flavor)) {
aset.add(new JobName(flavor.toString(), Locale.US));
dset.add(new DocumentName(file_gif, Locale.US));
job = serv.createPrintJob();
stream = getClass().getResourceAsStream(file_gif);
doc = new SimpleDoc(stream, flavor, dset);
System.out.println("\nPrinting on "
+ job.getPrintService().getName() + "...");
job.print(doc, aset);
System.out.println("File '" + file_gif + "' was printed as "
+ flavor.getRepresentationClassName());
}
flavor = DocFlavor.BYTE_ARRAY.JPEG;
if (serv.isDocFlavorSupported(flavor)) {
aset.add(new JobName(flavor.toString(), Locale.US));
dset.add(new DocumentName(file_gif, Locale.US));
job = serv.createPrintJob();
stream = getClass().getResourceAsStream(file_gif);
byte[] gif_buf;
byte[] buf = new byte[1024];