wood burning stoves 2.0*
The moose likes Java in General and the fly likes The problem of printing PDF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "The problem of printing PDF" Watch "The problem of printing PDF" New topic
Author

The problem of printing PDF

allen gu
Greenhorn

Joined: Jan 13, 2003
Posts: 6
The source is,
try {
FileInputStream jpegStream;
jpegStream = new FileInputStream("2.PDF");
if (jpegStream == null){
System.out.println("null");
System.exit(1);
}
System.out.println("Image size: "+ jpegStream.available());
DocFlavor myFormat = DocFlavor.INPUT_STREAM.PDF;
Doc myDoc = new SimpleDoc(jpegStream, myFormat, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(1));
// aset.add(MediaName.ISO_A4_WHITE);
// aset.add(Sides.ONE_SIDED);
PrintService services = PrintServiceLookup.lookupDefaultPrintService();
System.out.println("Print service: "+services.toString());
DocPrintJob job = services.createPrintJob();
job.print(myDoc, aset);
} catch (Exception pe) {
System.out.println(pe);
}
the result is
Image size: 12274
Print service: Win32 Printer : FinePrint 2000
sun.print.PrintJobFlavorException: invalid flavor
But when i print JPG file,then myFormat = DocFlavor.INPUT_STREAM.JPEG;
that's OK!
Now who can help me ?? thanx!
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923


If your dataobject is a jpeg, why do you specify PDF as format?
a rose is a rose is a rose and a jpg is a jpg and not a pdf.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The problem of printing PDF