[ 
https://issues.apache.org/jira/browse/PDFBOX-2275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14103720#comment-14103720
 ] 

Andreas Lehmkühler commented on PDFBOX-2275:
--------------------------------------------

I'm not happy with the patch as it fixes the symptom only but not the real 
cause.

The problem is, that the situation after parsing and after creating a pdf 
without saving can't be compared. All the information about direct/indirect 
objects, objects numbers etc. is generated when saving the pdf. There are a lot 
of parts in the code expecting all these information, like the one in 
PDResources.
So, the question is, should we somehow improve the creation process to produce 
all needed objects or just patch those parts which are affected because of 
expecting things which aren't there.

> ClassCastException in PDResources
> ---------------------------------
>
>                 Key: PDFBOX-2275
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2275
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.0
>            Reporter: Dominic Tubach
>         Attachments: PDResources.diff
>
>
> The code (added in revision 1606860)
> {code}
> COSObject cosObject = (COSObject)dict.getItem(objName);
> {code} in the method getXObjects() in PDResources fails with a 
> ClassCastException:
> bq. org.apache.pdfbox.cos.COSStream cannot be cast to 
> org.apache.pdfbox.cos.COSObject
> The document issuing this exception is created using the following code:
> {code}
> PDDocument doc = new PDDocument();    
> PDPage page = new PDPage();
> doc.addPage(page);
> PDImageXObject image = JPEGFactory.createFromStream(doc, imageStream);
> try (PDPageContentStream contentStream = new PDPageContentStream(doc, page, 
> false, false)) {
>     contentStream.drawImage(image, 20, 20);
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to