In version 1.8.8, LayerUtility.appendFormAsLayer() has a check to determine if
the layerName already exists in the targetDoc, and if it does, it throws an
IllegalArgumentException. My question is why? Would it not be better to
retrieve the PDOptionalContentGroup if it already exists and use it to add the
new form to the page?
I made the following change to my local copy, and on the tests that I've run,
it seems to cause no issues. Am I missing something in the spec that would
disallow this?
from:-----------------------if (ocprops.hasGroup(layerName)){ throw new
IllegalArgumentException("Optional group (layer) already exists: " +
layerName);}
PDOptionalContentGroup layer = new
PDOptionalContentGroup(layerName);ocprops.addGroup(layer);
to:-----------------------PDOptionalContentGroup layer = null;if
(ocprops.hasGroup(layerName)){ layer = ocprops.getGroup(layerName);}else{
layer = new PDOptionalContentGroup(layerName); ocprops.addGroup(layer);
}
Darin [email protected]