private void fillObjects(
PdfDataObject objectObject,
Collection<PdfObjectWrapper<?>> objects
)
{
PdfDataObject objectDataObject = File.resolve(objectObject);
if(objectDataObject instanceof PdfArray) // Multiple objects.
{
for(PdfDirectObject itemObject : (PdfArray)objectDataObject)
{fillObjects(itemObject,objects);}
}
else // Single object.
{
if(objectDataObject instanceof PdfDictionary) // Annotation.
objects.add(
Annotation.wrap((PdfReference)objectObject)
);
else if(objectDataObject instanceof PdfTextString) // Form field (associated to widget annotations).
objects.add(
getDocument().getForm().getFields().get(
(String)((PdfTextString)objectDataObject).getValue()
)
);
else // Invalid object type.
throw new RuntimeException(
"Invalid 'Hide' action target type (" + objectDataObject.getClass().getName() + ").\n"
+ "It should be either an annotation or a form field."
);
}
}