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
    org.apache.pdfbox.cos.COSObject
    java.lang.ClassCastException: org.apache.pdfbox.cos.COSStream cannot
    be cast to org.apache.pdfbox.cos.COSObject
         at
    org.apache.pdfbox.pdmodel.PDResources.getXObjects(PDResources.java:245)

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() -
    mediaBox.getWidth()*scale)/2,(mediaBox.getHeight()
    -mediaBox.getHeight()*scale)/2,mediaBox.getWidth()*scale,mediaBox.getHeight()*scale);
      contentStream.close();

    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



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