use of com.tom_roush.pdfbox.pdmodel.fdf.FDFField in project PdfBox-Android by TomRoush.
the class TestFDF method checkFields.
private void checkFields(String name) throws IOException, URISyntaxException {
FDFDocument fdf = FDFDocument.load(new File(TestFDF.class.getResource(name).toURI()));
fdf.saveXFDF(new PrintWriter(new ByteArrayOutputStream()));
List<FDFField> fields = fdf.getCatalog().getFDF().getFields();
assertEquals(2, fields.size());
assertEquals("Field1", fields.get(0).getPartialFieldName());
assertEquals("Field2", fields.get(1).getPartialFieldName());
assertEquals("Test1", fields.get(0).getValue());
assertEquals("Test2", fields.get(1).getValue());
PDDocument pdf = PDDocument.load(new File(TestFDF.class.getResource("/pdfbox/com/tom_roush/pdfbox/pdfparser/SimpleForm2Fields.pdf").toURI()));
PDAcroForm acroForm = pdf.getDocumentCatalog().getAcroForm();
acroForm.importFDF(fdf);
assertEquals("Test1", acroForm.getField("Field1").getValueAsString());
assertEquals("Test2", acroForm.getField("Field2").getValueAsString());
pdf.close();
fdf.close();
}
Aggregations