use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDPage method getAnnotations.
/**
* This will return a list of the annotations for this page.
*
* @param annotationFilter the annotation filter provided allowing to filter out specific annotations
* @return List of the PDAnnotation objects, never null. The returned list is backed by the
* annotations COSArray, so any adding or deleting in this list will change the document too.
*
* @throws IOException If there is an error while creating the annotation list.
*/
public List<PDAnnotation> getAnnotations(AnnotationFilter annotationFilter) throws IOException {
COSBase base = page.getDictionaryObject(COSName.ANNOTS);
if (base instanceof COSArray) {
COSArray annots = (COSArray) base;
List<PDAnnotation> actuals = new ArrayList<>();
for (int i = 0; i < annots.size(); i++) {
COSBase item = annots.getObject(i);
if (item == null) {
continue;
}
PDAnnotation createdAnnotation = PDAnnotation.createAnnotation(item);
if (annotationFilter.accept(createdAnnotation)) {
actuals.add(createdAnnotation);
}
}
return new COSArrayList<>(actuals, annots);
}
return new COSArrayList<>(page, COSName.ANNOTS);
}
use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDSeedValue method getDigestMethod.
/**
* An array of names indicating acceptable digest algorithms to use when
* signing. The value shall be one of <b>SHA1</b>, <b>SHA256</b>, <b>SHA384</b>,
* <b>SHA512</b>, <b>RIPEMD160</b>. The default value is implementation-specific.
*
* @return the digest method that shall be used by the signature handler
*/
public List<String> getDigestMethod() {
List<String> retval = null;
COSArray fields = (COSArray) dictionary.getDictionaryObject(COSName.DIGEST_METHOD);
if (fields != null) {
List<String> actuals = new ArrayList<>();
for (int i = 0; i < fields.size(); i++) {
String element = fields.getName(i);
if (element != null) {
actuals.add(element);
}
}
retval = new COSArrayList<>(actuals, fields);
}
return retval;
}
use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDSeedValue method getReasons.
/**
* If the Reasons array is provided and {@link #isReasonRequired()} indicates that
* Reasons is a required constraint, one of the reasons in the array shall be used
* for the signature dictionary; otherwise signing shall not take place. If the
* {@link #isReasonRequired()} indicates Reasons is an optional constraint, one of
* the reasons in the array may be chose or a custom reason can be provided.
*
* @return the reasons that should be used by the signature handler
*/
public List<String> getReasons() {
List<String> retval = null;
COSArray fields = (COSArray) dictionary.getDictionaryObject(COSName.REASONS);
if (fields != null) {
List<String> actuals = new ArrayList<>();
for (int i = 0; i < fields.size(); i++) {
String element = fields.getString(i);
if (element != null) {
actuals.add(element);
}
}
retval = new COSArrayList<>(actuals, fields);
}
return retval;
}
use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDAction method getNext.
/**
* This will get the next action, or sequence of actions, to be performed after this one.
* The value is either a single action dictionary or an array of action dictionaries
* to be performed in order.
*
* @return The Next action or sequence of actions.
*/
public List<PDAction> getNext() {
List<PDAction> retval = null;
COSBase next = action.getDictionaryObject(COSName.NEXT);
if (next instanceof COSDictionary) {
PDAction pdAction = PDActionFactory.createAction((COSDictionary) next);
retval = new COSArrayList<>(pdAction, next, action, COSName.NEXT);
} else if (next instanceof COSArray) {
COSArray array = (COSArray) next;
List<PDAction> actions = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
actions.add(PDActionFactory.createAction((COSDictionary) array.getObject(i)));
}
retval = new COSArrayList<>(actions, array);
}
return retval;
}
Aggregations