// TODO: add exception handling (at least some logger)
private void populateSignatureNames() {
        if (acroForm == null) {
            return;
        }
        List<Object[]> sorter = new ArrayList<>();
        for (Map.Entry<String, PdfFormField> entry : acroForm.getFormFields().entrySet()) {
            PdfFormField field = entry.getValue();
            PdfDictionary merged = field.getPdfObject();
            if (!PdfName.Sig.equals(merged.get(PdfName.FT)))
                continue;
            PdfDictionary v = merged.getAsDictionary(PdfName.V);
            if (v == null)
                continue;
            PdfString contents = v.getAsString(PdfName.Contents);
            if (contents == null) {
                continue;
            } else {
                contents.markAsUnencryptedObject();
            }
            PdfArray ro = v.getAsArray(PdfName.ByteRange);
            if (ro == null)
                continue;
            int rangeSize = ro.size();
            if (rangeSize < 2)
                continue;
            int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue();
            sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
        }
        Collections.sort(sorter, new SorterComparator());
        if (sorter.size() > 0) {
            try {
                if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
                    totalRevisions = sorter.size();
                else
                    totalRevisions = sorter.size() + 1;
            } catch (IOException e) {
                // TODO: add exception handling (at least some logger)
            }
            for (int k = 0; k < sorter.size(); ++k) {
                Object[] objs = sorter.get(k);
                String name = (String) objs[0];
                int[] p = (int[]) objs[1];
                p[1] = k + 1;
                sigNames.put(name, p);
                orderedSignatureNames.add(name);
            }
        }
    }
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
}
Collections.sort(sorter, new SorterComparator());
if (sorter.size() > 0) {
try {
if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
totalRevisions = sorter.size();
else
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
Object[] objs = sorter.get(k);
String name = (String) objs[0];
int[] p = (int[]) objs[1];
p[1] = k + 1;
sigNames.put(name, p);
orderedSignatureNames.add(name);
}
}
} else {
contents.markAsUnencryptedObject();
}
PdfArray ro = v.getAsArray(PdfName.ByteRange);
if (ro == null)
continue;
int rangeSize = ro.size();
if (rangeSize < 2)
continue;
int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue();
sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
}
Collections.sort(sorter, new SorterComparator());
if (sorter.size() > 0) {
try {
if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
totalRevisions = sorter.size();
else
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
Object[] objs = sorter.get(k);
String name = (String) objs[0];
int[] p = (int[]) objs[1];
p[1] = k + 1;
sigNames.put(name, p);
orderedSignatureNames.add(name);
}
}
}