Hi,
When I tried to print a PDF document using
JAVA 1.4 Printing API, I got the following exception.
______________________________________
Exception in
thread "main" sun.print.PrintJobFlavorException: invalid flavor
at sun.print.Win32PrintJob.print(Win32PrintJob.java:290)
at Printing.main(Printing.java:40)
_________________________________________________________________
I am able to print the same PDF document using Acrobat reader.
Is PDF format not supported in JAVA 1.4 printing API? or is something wrong in my code?
here is the sample JAVA program that I was using
import javax.print.*;
import javax.print.attribute.*;
import java.io.*;
public class Printing {
public static void main(
String args[]) throws Exception {
String filename = args[0];
PrintRequestAttributeSet pras =
new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
PrintService defaultService =
PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = defaultService.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
Thread.sleep(10000);
System.exit(0);
}
}
Thank you
Sumana