use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class PDAcroForm method exportFDF.
/**
* This will export all FDF form data.
*
* @return An FDF document used to export the document.
* @throws IOException If there is an error when exporting the document.
*/
public FDFDocument exportFDF() throws IOException {
FDFDocument fdf = new FDFDocument();
FDFCatalog catalog = fdf.getCatalog();
FDFDictionary fdfDict = new FDFDictionary();
catalog.setFDF(fdfDict);
List<FDFField> fdfFields = new ArrayList<FDFField>();
List<PDField> fields = getFields();
for (PDField field : fields) {
fdfFields.add(field.exportFDF());
}
fdfDict.setID(document.getDocument().getDocumentID());
if (!fdfFields.isEmpty()) {
fdfDict.setFields(fdfFields);
}
return fdf;
}
use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class PDNonTerminalField method exportFDF.
@Override
FDFField exportFDF() throws IOException {
FDFField fdfField = new FDFField();
fdfField.setPartialFieldName(getPartialName());
fdfField.setValue(getValue());
List<PDField> children = getChildren();
List<FDFField> fdfChildren = new ArrayList<FDFField>();
for (PDField child : children) {
fdfChildren.add(child.exportFDF());
}
fdfField.setKids(fdfChildren);
return fdfField;
}
use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class PDAcroForm method importFDF.
/**
* This method will import an entire FDF document into the PDF document
* that this acroform is part of.
*
* @param fdf The FDF document to import.
*
* @throws IOException If there is an error doing the import.
*/
public void importFDF(FDFDocument fdf) throws IOException {
List<FDFField> fields = fdf.getCatalog().getFDF().getFields();
if (fields != null) {
for (FDFField field : fields) {
FDFField fdfField = field;
PDField docField = getField(fdfField.getPartialFieldName());
if (docField != null) {
docField.importFDF(fdfField);
}
}
}
}
use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class PDTerminalField method exportFDF.
@Override
FDFField exportFDF() throws IOException {
FDFField fdfField = new FDFField();
fdfField.setPartialFieldName(getPartialName());
fdfField.setValue(getCOSObject().getDictionaryObject(COSName.V));
return fdfField;
}
use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class PDNonTerminalField method importFDF.
@Override
void importFDF(FDFField fdfField) throws IOException {
super.importFDF(fdfField);
List<FDFField> fdfKids = fdfField.getKids();
List<PDField> children = getChildren();
for (int i = 0; fdfKids != null && i < fdfKids.size(); i++) {
for (COSObjectable pdKid : children) {
if (pdKid instanceof PDField) {
PDField pdChild = (PDField) pdKid;
FDFField fdfChild = fdfKids.get(i);
String fdfName = fdfChild.getPartialFieldName();
if (fdfName != null && fdfName.equals(pdChild.getPartialName())) {
pdChild.importFDF(fdfChild);
}
}
}
}
}
Aggregations