// Fills in a PDF form and saves the result public void fillForm(object sender, EventArgs e) { try { // Load the document and get the AcroForm using (var document = PDDocument.Load(assetManager.Open("FormTest.pdf"))) using (var docCatalog = document.DocumentCatalog) using (var acroForm = docCatalog.AcroForm) { // Fill the text field using (var field = (PDTextField)acroForm.GetField("TextField")) { field.Value = "Filled Text Field"; // Optional: don't allow this field to be edited field.ReadOnly = true; } using (var checkbox = acroForm.GetField("Checkbox")) { ((PDCheckbox)checkbox).Check(); } using (var radio = acroForm.GetField("Radio")) { ((PDRadioButton)radio).Value = "Second"; } // TODO: Use List<int> using (var listbox = acroForm.GetField("ListBox")) { List <Integer> listValues = new List <Integer>(); listValues.Add(Integer.ValueOf(1.ToString())); listValues.Add(Integer.ValueOf(2.ToString())); ((PDListBox)listbox).SelectedOptionsIndex = listValues; } /* * // TODO: Fix Exception * using (var dropdown = acroForm.GetField("Dropdown")) * { * IList<string> list = new List<string>(); * list.Add("Hello"); * ((PDComboBox)dropdown).Value = list; * } */ string path = root.AbsolutePath + "/FilledForm.pdf"; tv.Text = "Saved filled form to " + path; document.Save(path); document.Close(); } } catch (IOException ex) { Log.Error("PdfBox-Android-Sample", "Exception thrown while filling form fields", ex); } }