use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDAcroForm method getFields.
/**
* This will return all of the documents root fields.
*
* A field might have children that are fields (non-terminal field) or does not
* have children which are fields (terminal fields).
*
* The fields within an AcroForm are organized in a tree structure. The documents root fields
* might either be terminal fields, non-terminal fields or a mixture of both. Non-terminal fields
* mark branches which contents can be retrieved using {@link PDNonTerminalField#getChildren()}.
*
* @return A list of the documents root fields, never null. If there are no fields then this
* method returns an empty list.
*/
public List<PDField> getFields() {
COSArray cosFields = (COSArray) dictionary.getDictionaryObject(COSName.FIELDS);
if (cosFields == null) {
return Collections.emptyList();
}
List<PDField> pdFields = new ArrayList<>();
for (int i = 0; i < cosFields.size(); i++) {
COSDictionary element = (COSDictionary) cosFields.getObject(i);
if (element != null) {
PDField field = PDField.fromDictionary(this, element, null);
if (field != null) {
pdFields.add(field);
}
}
}
return new COSArrayList<>(pdFields, cosFields);
}
use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class PDSeedValue method getLegalAttestation.
/**
* (Optional, PDF 1.6) An array of text strings that specifying possible legal
* attestations.
*
* @return the reasons that should be used by the signature handler
*/
public List<String> getLegalAttestation() {
List<String> retval = null;
COSArray fields = (COSArray) dictionary.getDictionaryObject(COSName.LEGAL_ATTESTATION);
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 PDSeedValue method getSubFilter.
/**
* If <b>SubFilter</b> is not null and the {@link #isSubFilterRequired()} indicates this
* entry is a required constraint, then the first matching encodings shall be used when
* signing; otherwise, signing shall not take place. If {@link #isSubFilterRequired()}
* indicates that this is an optional constraint, then the first matching encoding shall
* be used if it is available. If it is not available, a different encoding may be used
* instead.
*
* @return the subfilter that shall be used by the signature handler
*/
public List<String> getSubFilter() {
List<String> retval = null;
COSArray fields = (COSArray) dictionary.getDictionaryObject(COSName.SUB_FILTER);
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 PDNonTerminalField method getChildren.
/**
* Returns this field's children. These may be either terminal or non-terminal fields.
*
* @return the list of child fields. Be aware that this list is <i>not</i> backed by the
* children of the field, so adding or deleting has no effect on the PDF document until you call
* {@link #setChildren(java.util.List) setChildren()} with the modified list.
*/
public List<PDField> getChildren() {
// TODO: why not return a COSArrayList like in PDPage.getAnnotations() ?
List<PDField> children = new ArrayList<>();
COSArray kids = (COSArray) getCOSObject().getDictionaryObject(COSName.KIDS);
for (int i = 0; i < kids.size(); i++) {
COSBase kid = kids.getObject(i);
if (kid instanceof COSDictionary) {
if (kid.getCOSObject() == this.getCOSObject()) {
LOG.warn("Child field is same object as parent");
continue;
}
PDField field = PDField.fromDictionary(getAcroForm(), (COSDictionary) kid, this);
if (field != null) {
children.add(field);
}
}
}
return children;
}
use of org.apache.pdfbox.pdmodel.common.COSArrayList in project pdfbox by apache.
the class FDFDictionary method getEmbeddedFDFs.
/**
* This will get the list of embedded FDF entries, or null if the entry is null. This will return a list of
* PDFileSpecification objects.
*
* @return A list of embedded FDF files.
*
* @throws IOException If there is an error creating the file spec.
*/
public List<PDFileSpecification> getEmbeddedFDFs() throws IOException {
List<PDFileSpecification> retval = null;
COSArray embeddedArray = (COSArray) fdf.getDictionaryObject(COSName.EMBEDDED_FDFS);
if (embeddedArray != null) {
List<PDFileSpecification> embedded = new ArrayList<>();
for (int i = 0; i < embeddedArray.size(); i++) {
embedded.add(PDFileSpecification.createFS(embeddedArray.get(i)));
}
retval = new COSArrayList<>(embedded, embeddedArray);
}
return retval;
}
Aggregations