Я пытаюсь отключить OCG с помощью pdfbox.Я попробовал приведенный ниже код, но это не отключение OCG.Любая помощь очень ценится.
public void OCGDelete(PDDocument doc, String OCName) throws IOException {
PDDocumentCatalog catalog = doc.getDocumentCatalog();
PDOptionalContentProperties props= catalog.getOCProperties();
ByteArrayOutputStream pdfOutStream = new ByteArrayOutputStream();
List<String> ocgNames = Lists.newArrayList(props.getGroupNames());
if(ocgNames.contains(OCGName)) {
PDOptionalContentGroup group = props.getGroup(OCGName);
props.setGroupEnabled(group, **false**);
}
doc.getDocumentCatalog().setOCProperties(props);
doc.save(pdfOutStream);
FileOutputStream out = new FileOutputStream(
new File("test/emitted/OCGResult.pdf"));
out.write(pdfOutStream.toByteArray());
out.close();