Ugh, formatting mess.
For more info, this is the "addOCGs:OCG" log line just before the error
message:
10:53:09.765 [etrix SwingWorker[0]] DEBUG ImposedPDFEngine - addOCGs:
OCG
COSDictionary{COSName{Name}:COSObject{COSNull{}};COSName{Type}:COSObject{COSName{OCG}};}
On 11/21/2023 10:56 AM, John Lussmyer wrote:
I'm using PDFBox 3.0.0 to combine some PDF files. One of the files
uses an Optional Content Group.
Note that this code has been working just fine for many other files
both with and without OCG's.
For this file, I get this exception:
java.lang.IllegalArgumentException: Provided dictionary is not of type
'COSName{OCG}'
at
org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentGroup.<init>(PDOptionalContentGroup.java:48)
~[pdfbox-3.0.0.jar:3.0.0]
Code:
*if*(obj*instanceof*COSDictionary) {
COSDictionary dict= (COSDictionary) obj;
COSName dType= dict.getCOSName(COSName.*/TYPE/*);
*if*(dType== *null*) {
*continue*;
}
*if*(dType.equals(COSName.*/OCG/*)) {
*/log/*.debug("addOCGs: OCG {}", dict);
PDOptionalContentGroup grp= *new*PDOptionalContentGroup(dict);
ocProps.addGroup(grp);
ocProps.setGroupEnabled(grp, layersON.contains(grp.getName()));
changed= *true*;
}
}
It's failing on the "new PDOptionalContentGroup(dict)" call.
Any ideas on why?