pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shea Martin <shea.mar...@me.com>
Subject Re: Can view document, but getPrintable fails due to unknown compression of zip stream
Date Thu, 09 Jun 2011 14:46:51 GMT
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, samfree@me.com 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>




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message