pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A.D. Kent" <alden.k...@gmail.com>
Subject Error with PDFRenderer.renderImageWithDPI
Date Wed, 09 Jul 2014 19:31:13 GMT
Hello PDFBox community,

I have a working model that copies & scales PDF pages from one 
PDDocument to another (thanks Maruan), however, when I attempt to 
convert the target document to an image via PDFRenderer, I am getting 
the following error:

    SEVERE: Error converting PDF to TIFF:
    org.apache.pdfbox.cos.COSStream cannot be cast to
    java.lang.ClassCastException: org.apache.pdfbox.cos.COSStream cannot
    be cast to org.apache.pdfbox.cos.COSObject

For backgrounder, I am using a PDFormXObject to copy the contents of a 
source page and place within a new page within the target document.  
This approach allows me to scale the object down, allowing for more 
margin to accommodate OMR marks.  Some brief code:

    PDPageContentStream contentStream = new
    PDPageContentStream(targetDoc, targetPage, false, false);
    contentStream.drawXObject(form, (mediaBox.getWidth() -

    return targetDoc;

If I save the targetDoc to disk, then load into a new PDDocument, I do 
not get this error.  However, if I simply attempt to render the 
targetDoc to an image, I get the stacktrace above.

Please advise.

A.D. Kent

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