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 16:47:17 GMT
Solution:
pdf.decrypt("");

I guess this is somehting I have to check from now on. Perhaps a better erorr message would
help people with this in the future.

CHeers,
~S
On 2011-06-09, at 10:29 AM, Shea Martin wrote:

> 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, 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>
> 
> 
> 

----------------
Shea Martin
<contact info>




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