BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
XFA from Creation:
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a text element and add the properties.
PdfXfaTextElement textElement = new PdfXfaTextElement("Hello World!");
//Add the field to the XFA form. mainForm.Fields.Add(textElement);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the PDF document to stream.
MemoryStream stream = new MemoryStream();
document.Save(stream, PdfXfaType.Dynamic);
document.Close();
XFA form filling:
//Load the existing XFA document
PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(inputFileStream);
//Load the existing XFA form
PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm;
//Get the loaded text box field.
PdfLoadedXfaTextBoxField loadedTextBox = (loadedForm.Fields["form[0].subform1[0].firstName[0]"] as PdfLoadedXfaForm).Fields["text[0]"] as PdfLoadedXfaTextBoxField;
//fill the text box
loadedTextBox.Text = "First Name";
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream);
//Close the document.
loadedDocument.Close(); |