I should also note that I am printing the MyPdfDoc using printJob.setPrintable(). The PrintPDF utility which is part of PDF box, uses printJob.setPageable(). Should this matter?
On 2011-06-09, at 7:46 AM, [email protected] wrote: > > Hello, > > I am using PDFBox to print PDF's. I have come across a PDF which I can not > print. FlateFilter is thrown a ZipException due to an unknown compression > method. Yet, I know PDFBox can handle the file, because PDFReader, and > PrintPDF utilities work fine. (aside: Speaking of which, could the error > message printed when this happens be more specific than "Stop reading corrupt > stream". ) > > So I am not sure if the bug is in my code or PDFBox's; this is the code I am > using to print, which works with most PDF's. > > public class MyPdfDoc implements Printable > { > > private PDDocument pdfDoc; > > public MyPdfDoc( String path ) > { > try > { > pdfDoc = PDDocument.load(path); > } > catch( IOException e ) > { > log.severe("failed to load " + path + ": " + e); > pdfDoc = null; > } > } > > @Override > public int print( Graphics graphics, PageFormat pageFormat, int > pageIndex ) throws PrinterException > { > if( pdfDoc == null || pageIndex >= pdfDoc.getNumberOfPages() ) > { > return NO_SUCH_PAGE; > } > > Printable printable = pdfDoc.getPrintable(pageIndex); > return printable.print(graphics, pageFormat, pageIndex); > } > } > > Any help appreciated, thanks. > ~S ---------------- Shea Martin <contact info>

