You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Chris Naude (JIRA)" <ji...@apache.org> on 2012/06/24 00:16:42 UTC

[jira] [Commented] (PDFBOX-1347) java.lang.ClassCastException: org.apache.pdfbox.cos.COSString cannot be cast to org.apache.pdfbox.cos.COSDictionary

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

Chris Naude commented on PDFBOX-1347:
-------------------------------------

As a work around I modified PDOutlineNode.java and added a try catch for the casting exception. I'm sure there is a better way to handle this,


    public PDOutlineItem getFirstChild()
    {
        PDOutlineItem last = null;
        COSDictionary lastDic;
        try
        {
            lastDic = (COSDictionary)node.getDictionaryObject( "First" );
        }
        catch (ClassCastException e)
        {
            return last;
        }
        if( lastDic != null )
        {
            last = new PDOutlineItem( lastDic );
        }
        return last;
    }

                
> java.lang.ClassCastException: org.apache.pdfbox.cos.COSString cannot be cast to org.apache.pdfbox.cos.COSDictionary
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-1347
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1347
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.7.0, 1.8.0
>         Environment: Windows 7 with Oracle JDK 1.6.0_33
>            Reporter: Chris Naude
>         Attachments: Image 1.png
>
>
> I'm attempting to merge two pdf's and I am getting this exception. This only occurs for specific PDF files. I am able to merge other PDF's without any issues.
> java.lang.ClassCastException: org.apache.pdfbox.cos.COSString cannot be cast to org.apache.pdfbox.cos.COSDictionary
> 	at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.getFirstChild(PDOutlineNode.java:161)
> 	at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:339)
> 	at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:188)
> 	at me.cnaude.pdfboxgui.MainForm$MergeThread.run(MainForm.java:355)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira