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

Andreas Küllinger commented on PDFBOX-4814:
-------------------------------------------

There is my easy code to reproduce it with merge utility:

package pdfboxtest;

import java.io.File;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.apache.pdfbox.pdmodel.PDDocument;

public class Test2
{

public static void main(String[] args)
 {
 File f1 = new File("C:\\PDFnoocg.pdf");
 File f2 = new File("C:\\PDFocg1.pdf");
 File f3 = new File("C:\\PDFocg2.pdf");
 File fr = new File("C:\\merged.pdf");
 try {
 PDFMergerUtility merge = new PDFMergerUtility();
 PDDocument pd1 = PDDocument.load(f1);
 PDDocument pd2 = PDDocument.load(f2);
 PDDocument pd3 = PDDocument.load(f3);
 merge.appendDocument(pd1, pd2);
 pd1.save(fr);
 pd1.close();
 pd2.close();
 PDDocument pdr = PDDocument.load(fr);
 merge.appendDocument(pdr, pd3);
 pdr.save(fr);
 pdr.close();
 pd3.close();
 }
 catch (Exception e) {
 System.out.println("Error" + e.getLocalizedMessage());
 e.printStackTrace();
 }
 }
}[^PDFocg2.pdf]

> Wrong COSType for OCProperties after merge
> ------------------------------------------
>
>                 Key: PDFBOX-4814
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4814
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.19
>            Reporter: Andreas Küllinger
>            Priority: Major
>
> If you merge a PDF document with OCProperties to a PDF document without 
> OCProperties, the result of the merge is that the OCProperties type is no 
> longer a COSDictionary but a COSObject. If a third document with OCProperties 
> is merged with the previously created merge result, this leads to the 
> following ClassCastException:
> org.apache.pdfbox.cos.COSObject cannot be cast to 
> org.apache.pdfbox.cos.COSDictionary at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneMerge(PDFCloneUtility.java:227)
>  at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneMerge(PDFCloneUtility.java:229)
>  at 
> org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:730)
>  at pdfboxtest.Test.main(Test.java:38)
> According to PDF Specification, OCProperties is always a dictionary.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to