I have removed my code from suspicion, the following fails with pdfbox,
jempbox, and fontbox in my classpath. But if I put run pdfbox-app, as a
PrintPDF, or PDFReader it works on the same pdf. The app jar must include
something extra?
The following produces the same corrupt stream error.
static void main(String[] args)
{
PDDocument pdf = PDDocument.load("testdata/cash_for_keys.pdf");
pdf.silentPrint();
}
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>