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

Vadimo commented on PDFBOX-2687:
--------------------------------

It is only partly fixed. If you take a look at getOutputIntent and 
addOutputIntent they implement the same logic.

{code:title=PDDocumentCatalog.java|borderStyle=solid}
2           public List<PDOutputIntent> getOutputIntent () {
453             List<PDOutputIntent> retval = new ArrayList<PDOutputIntent>();
454             COSArray array = 
(COSArray)root.getDictionaryObject(COSName.OUTPUT_INTENTS);
455             if (array!=null) {
456                 for (COSBase cosBase : array)
457                 {
458                     PDOutputIntent oi = new 
PDOutputIntent((COSDictionary)cosBase);
459                     retval.add(oi);
460                 }
461             }
462             return retval;
463         }
464     
465         /**
466          * Add an OutputIntent to the list.
467          * 
468          * If there is not OutputIntent, the list is created and the first
469          * element added.
470          * 
471          * @param outputIntent the OutputIntent to add.
472          */
473         public void addOutputIntent (PDOutputIntent outputIntent) {
474             COSArray array = (COSArray)root.getItem(COSName.OUTPUT_INTENTS);
475             if (array==null) {
476                 array = new COSArray();
477                 root.setItem(COSName.OUTPUT_INTENTS, array);
478             }
479             array.add(outputIntent.getCOSObject());
480         }
{code}

> ClassCastException when trying to get OutputIntents
> ---------------------------------------------------
>
>                 Key: PDFBOX-2687
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2687
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.8.6, 1.8.8, 2.0.0
>            Reporter: Maruan Sahyoun
>            Assignee: Maruan Sahyoun
>             Fix For: 1.8.9, 2.0.0
>
>
> Form the users mailing list:
> Im trying to call "List<PDOutputIntent> outputIntents = 
> doc.getDocumentCatalog().getOutputIntent();" on 
> https://www.dropbox.com/s/u7gwgxpq1656x4d/acme_invoice-42_a1b.pdf?dl=0 
> <https://www.dropbox.com/s/u7gwgxpq1656x4d/acme_invoice-42_a1b.pdf?dl=0>
> The Stacktrace is:
> Caused by: java.lang.ClassCastException: org.apache.pdfbox.cos.COSObject 
> cannot be cast to org.apache.pdfbox.cos.COSArray
>       at 
> org.apache.pdfbox.pdmodel.PDDocumentCatalog.addOutputIntent(PDDocumentCatalog.java:474)
>       
> Should the code really contain a cast in PDDocumentCatalog.java:474



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to