New form
Author: g | 2025-04-24
Another way to say New Form? Synonyms for New Form (other words and phrases for New Form).
Creating a New Form - Ninja Forms
PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text box field and add the properties.PdfXfaTextBoxField textBoxField = new PdfXfaTextBoxField("textBoxField", new SizeF(200, 20));//Set the caption text.textBoxField.Caption.Text = "Fist Name";//Add the text box to the XFA form.mainForm.Fields.Add(textBoxField);//Set the form as read only.mainForm.ReadOnly = true;//Add the XFA form to the document.document.XfaForm = mainForm;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.document.Save(stream,PdfXfaType.Dynamic);//Close the document.document.Close();//Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text box field and add the properties.PdfXfaTextBoxField textBoxField = new PdfXfaTextBoxField("textBoxField", new SizeF(200, 20));//Set the caption text.textBoxField.Caption.Text = "Fist Name";//Add the text box to the XFA form.mainForm.Fields.Add(textBoxField);//Set the form as read only.mainForm.ReadOnly = true;//Add the XFA form to the document.document.XfaForm = mainForm;//Save the document.document.Save("XfaForm.pdf", PdfXfaType.Dynamic);//Close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a text box field and add the propertiesDim textBoxField As New PdfXfaTextBoxField("textBoxField", New SizeF(200, 20))'Set the caption texttextBoxField.Caption.Text = "Fist Name"'Add the text box to the XFA formmainForm.Fields.Add(textBoxField)'Set the form as read onlymainForm.ReadOnly = True'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Dynamic)'Close the documentdocument.Close()You can download a complete working sample from GitHub.The below code snippet illustrates how to set the ReadOnly property to an existing PDF document.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //Load the PDF document.FileStream docStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);//Load the existing XFA document.PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(docStream);//Load the existing XFA form.PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm;//Set the form as read only.loadedForm.ReadOnly = true;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.loadedDocument.Save(stream);//Close the document.loadedDocument.Close();//Load the existing PDF document.PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument("input.pdf");//Load the existing XFA form.PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm;//Set the form as read only.loadedForm.ReadOnly = true;//Save the document.loadedDocument.Save("output.pdf");//Close the document.loadedDocument.Close();'Load the existing PDF document Dim loadedDocument As New PdfLoadedXfaDocument("input.pdf")'Load the existing XFA formDim loadedForm As PdfLoadedXfaForm = loadedDocument.XfaForm'Set the form as read onlyloadedForm.ReadOnly = True'Save the document loadedDocument.Save("output.pdf")'Close the documentloadedDocument.Close()You can download a complete working sample from GitHub.Flattening XFA Form fieldsThe form field editing or filling capabilities can be removed by flattening the PDF document.The Essential® PDF flattens a form field by removing the existing form field and replacing it with graphical objects that will resemble the form field and cannot be edited. This can be achieved by enabling the Flatten property of PdfLoadedXfaDocument.The following code snippet illustrates how to flatten the XFA form field.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //PDF doesn't support flattening XFA form fields in C# .NET Cross platforms.//Load the existing document.PdfLoadedXfaDocument ldoc = new PdfLoadedXfaDocument("input.pdf");//Set flatten.ldoc.Flatten = true;//Save the document.ldoc.Save("output.pdf");//Close the document.ldoc.Close();'Load the existing documentDim ldoc As New PdfLoadedXfaDocument("input.pdf")'Set flattenldoc.Flatten = True'Save the documentldoc.Save("output.pdf")'Close the documentldoc.Close()You can download a complete working sample from GitHub.Removing the dynamic form fields from an existing XFA documentYou can remove the dynamic XFA form fields by using Remove method of PdfLoadedXfaFieldCollection class. Another way to say New Form? Synonyms for New Form (other words and phrases for New Form). PdfXfaType.Dynamic);//close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(xfaPage,PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a numeric field and add the propertiesDim numericField As New PdfXfaNumericField("numericField", New SizeF(200, 20))'Set the caption textnumericField.Caption.Text = "Numeric Field"'Set the pattern stringnumericField.PatternString = "zzzzzzzzz9"'Add the field to the XFA formmainForm.Fields.Add(numericField)'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Dynamic)'close the documentdocument.Close()You can download a complete working sample from GitHub.Adding nested sub formsYou can add the nested sub forms by using PdfXfaForm class. The below code snippet explains this.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a font.PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text element.PdfXfaTextElement element = new PdfXfaTextElement("Main Form", font, 400, 20);//Add the field to the XFA form.mainForm.Fields.Add(element);//Create a form.PdfXfaForm form1 = new PdfXfaForm(PdfXfaFlowDirection.Vertical, 400);//Create a text element.PdfXfaTextElement element1 = new PdfXfaTextElement("First Form", font, 400, 20);form1.Fields.Add(element1);//Create a form.PdfXfaForm form2 = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400);//Create a text element.PdfXfaTextElement element2 = new PdfXfaTextElement("Second Form", font, 400, 20);form2.Fields.Add(element2);form1.Fields.Add(form2);//Add the field to the XFA form.mainForm.Fields.Add(form1);//Add the XFA form to the document.document.XfaForm = mainForm;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.document.Save(stream,PdfXfaType.Dynamic);//Close the document.document.Close();//Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a font.PdfFont font = new PdfStandardFont(xfaPage,PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize ().Width);//Create a text element.PdfXfaTextElement element = new PdfXfaTextElement("Main Form", font, 400, 20); //Add the field to the XFA form.mainForm.Fields.Add(element);//Create a form.PdfXfaForm form1 = new PdfXfaForm(PdfXfaFlowDirection.Vertical, 400);//Create a text element.PdfXfaTextElement element1 = new PdfXfaTextElement("First Form", font, 400, 20);form1.Fields.Add(element1);//Create a form.PdfXfaForm form2 = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400);//Create a text element.PdfXfaTextElement element2 = new PdfXfaTextElement ("Second Form", font,400,20);form2.Fields.Add(element2);form1.Fields.Add(form2);//Add the field to the XFA form.mainForm.Fields.Add(form1);//Add the XFA form to the document.document.XfaForm = mainForm;//Save the document.document.Save("XfaForm.pdf", PdfXfaType.Static);//Close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a fontDim font As PdfFont = New PdfStandardFont(xfaPage,PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold)'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a text elementDim element As New PdfXfaTextElement("Main Form", font, 400, 20)'Add the field to the XFA formmainForm.Fields.Add(element)'Create a formDim form1 As New PdfXfaForm(PdfXfaFlowDirection.Vertical, 400)'Create a text elementDim element1 As New PdfXfaTextElement("First Form", font, 400, 20)form1.Fields.Add(element1)'Create a new PDF XFA form with horizontal flow directionDim form2 As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400)'Create a text elementDim element2 As New PdfXfaTextElement("Second Form", font,400,20)form2.Fields.Add(element2)form1.Fields.Add(form2)'Add the field to the XFA formmainForm.Fields.Add(form1)'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Static)'Close the documentdocument.Close()You can download a complete working sample from GitHub.Formatting XFA form fieldsWorking with alignmentsXFA support both the horizontal and vertical alignments.Horizontal alignmentYou can add the horizontal alignments in XFA form fields through HorizontalAlignment property by using PdfXfaHorizontalAlignment Enum. The below code snippet illustrates this.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific]Comments
PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text box field and add the properties.PdfXfaTextBoxField textBoxField = new PdfXfaTextBoxField("textBoxField", new SizeF(200, 20));//Set the caption text.textBoxField.Caption.Text = "Fist Name";//Add the text box to the XFA form.mainForm.Fields.Add(textBoxField);//Set the form as read only.mainForm.ReadOnly = true;//Add the XFA form to the document.document.XfaForm = mainForm;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.document.Save(stream,PdfXfaType.Dynamic);//Close the document.document.Close();//Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text box field and add the properties.PdfXfaTextBoxField textBoxField = new PdfXfaTextBoxField("textBoxField", new SizeF(200, 20));//Set the caption text.textBoxField.Caption.Text = "Fist Name";//Add the text box to the XFA form.mainForm.Fields.Add(textBoxField);//Set the form as read only.mainForm.ReadOnly = true;//Add the XFA form to the document.document.XfaForm = mainForm;//Save the document.document.Save("XfaForm.pdf", PdfXfaType.Dynamic);//Close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a text box field and add the propertiesDim textBoxField As New PdfXfaTextBoxField("textBoxField", New SizeF(200, 20))'Set the caption texttextBoxField.Caption.Text = "Fist Name"'Add the text box to the XFA formmainForm.Fields.Add(textBoxField)'Set the form as read onlymainForm.ReadOnly = True'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Dynamic)'Close the documentdocument.Close()You can download a complete working sample from GitHub.The below code snippet illustrates how to set the ReadOnly property to an existing PDF document.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //Load the PDF document.FileStream docStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);//Load the existing XFA document.PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(docStream);//Load the existing XFA form.PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm;//Set the form as read only.loadedForm.ReadOnly = true;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.loadedDocument.Save(stream);//Close the document.loadedDocument.Close();//Load the existing PDF document.PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument("input.pdf");//Load the existing XFA form.PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm;//Set the form as read only.loadedForm.ReadOnly = true;//Save the document.loadedDocument.Save("output.pdf");//Close the document.loadedDocument.Close();'Load the existing PDF document Dim loadedDocument As New PdfLoadedXfaDocument("input.pdf")'Load the existing XFA formDim loadedForm As PdfLoadedXfaForm = loadedDocument.XfaForm'Set the form as read onlyloadedForm.ReadOnly = True'Save the document loadedDocument.Save("output.pdf")'Close the documentloadedDocument.Close()You can download a complete working sample from GitHub.Flattening XFA Form fieldsThe form field editing or filling capabilities can be removed by flattening the PDF document.The Essential® PDF flattens a form field by removing the existing form field and replacing it with graphical objects that will resemble the form field and cannot be edited. This can be achieved by enabling the Flatten property of PdfLoadedXfaDocument.The following code snippet illustrates how to flatten the XFA form field.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //PDF doesn't support flattening XFA form fields in C# .NET Cross platforms.//Load the existing document.PdfLoadedXfaDocument ldoc = new PdfLoadedXfaDocument("input.pdf");//Set flatten.ldoc.Flatten = true;//Save the document.ldoc.Save("output.pdf");//Close the document.ldoc.Close();'Load the existing documentDim ldoc As New PdfLoadedXfaDocument("input.pdf")'Set flattenldoc.Flatten = True'Save the documentldoc.Save("output.pdf")'Close the documentldoc.Close()You can download a complete working sample from GitHub.Removing the dynamic form fields from an existing XFA documentYou can remove the dynamic XFA form fields by using Remove method of PdfLoadedXfaFieldCollection class.
2025-04-16PdfXfaType.Dynamic);//close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(xfaPage,PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a numeric field and add the propertiesDim numericField As New PdfXfaNumericField("numericField", New SizeF(200, 20))'Set the caption textnumericField.Caption.Text = "Numeric Field"'Set the pattern stringnumericField.PatternString = "zzzzzzzzz9"'Add the field to the XFA formmainForm.Fields.Add(numericField)'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Dynamic)'close the documentdocument.Close()You can download a complete working sample from GitHub.Adding nested sub formsYou can add the nested sub forms by using PdfXfaForm class. The below code snippet explains this.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific] //Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a font.PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width);//Create a text element.PdfXfaTextElement element = new PdfXfaTextElement("Main Form", font, 400, 20);//Add the field to the XFA form.mainForm.Fields.Add(element);//Create a form.PdfXfaForm form1 = new PdfXfaForm(PdfXfaFlowDirection.Vertical, 400);//Create a text element.PdfXfaTextElement element1 = new PdfXfaTextElement("First Form", font, 400, 20);form1.Fields.Add(element1);//Create a form.PdfXfaForm form2 = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400);//Create a text element.PdfXfaTextElement element2 = new PdfXfaTextElement("Second Form", font, 400, 20);form2.Fields.Add(element2);form1.Fields.Add(form2);//Add the field to the XFA form.mainForm.Fields.Add(form1);//Add the XFA form to the document.document.XfaForm = mainForm;//Create memory stream.MemoryStream stream = new MemoryStream();//Save the document to memory stream.document.Save(stream,PdfXfaType.Dynamic);//Close the document.document.Close();//Create a new PDF XFA document.PdfXfaDocument document = new PdfXfaDocument();//Add new XFA page.PdfXfaPage xfaPage = document.Pages.Add();//Create a font.PdfFont font = new PdfStandardFont(xfaPage,PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);//Create a new PDF XFA form with horizontal flow direction.PdfXfaForm mainForm = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize ().Width);//Create a text element.PdfXfaTextElement element = new PdfXfaTextElement("Main Form", font, 400, 20); //Add the field to the XFA form.mainForm.Fields.Add(element);//Create a form.PdfXfaForm form1 = new PdfXfaForm(PdfXfaFlowDirection.Vertical, 400);//Create a text element.PdfXfaTextElement element1 = new PdfXfaTextElement("First Form", font, 400, 20);form1.Fields.Add(element1);//Create a form.PdfXfaForm form2 = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400);//Create a text element.PdfXfaTextElement element2 = new PdfXfaTextElement ("Second Form", font,400,20);form2.Fields.Add(element2);form1.Fields.Add(form2);//Add the field to the XFA form.mainForm.Fields.Add(form1);//Add the XFA form to the document.document.XfaForm = mainForm;//Save the document.document.Save("XfaForm.pdf", PdfXfaType.Static);//Close the document.document.Close();'Create a new PDF XFA documentDim document As New PdfXfaDocument()'Add new XFA pageDim xfaPage As PdfXfaPage = document.Pages.Add()'Create a fontDim font As PdfFont = New PdfStandardFont(xfaPage,PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold)'Create a new PDF XFA form with horizontal flow directionDim mainForm As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, xfaPage.GetClientSize().Width)'Create a text elementDim element As New PdfXfaTextElement("Main Form", font, 400, 20)'Add the field to the XFA formmainForm.Fields.Add(element)'Create a formDim form1 As New PdfXfaForm(PdfXfaFlowDirection.Vertical, 400)'Create a text elementDim element1 As New PdfXfaTextElement("First Form", font, 400, 20)form1.Fields.Add(element1)'Create a new PDF XFA form with horizontal flow directionDim form2 As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 400)'Create a text elementDim element2 As New PdfXfaTextElement("Second Form", font,400,20)form2.Fields.Add(element2)form1.Fields.Add(form2)'Add the field to the XFA formmainForm.Fields.Add(form1)'Add the XFA form to the documentdocument.XfaForm = mainForm'Save the documentdocument.Save("XfaForm.pdf", PdfXfaType.Static)'Close the documentdocument.Close()You can download a complete working sample from GitHub.Formatting XFA form fieldsWorking with alignmentsXFA support both the horizontal and vertical alignments.Horizontal alignmentYou can add the horizontal alignments in XFA form fields through HorizontalAlignment property by using PdfXfaHorizontalAlignment Enum. The below code snippet illustrates this.C# [Cross-platform]C# [Windows-specific]VB.NET [Windows-specific]
2025-04-15A PDF page, please use functions Form.getControlCount and Form.getControl.To import form data from an XML file, please use function Form.importFromXML; to export form data to an XML file, please use function Form.exportToXML.To retrieve form filler object, please use function Form.getFormFiller.To import form data from a FDF/XFDF file or export such data to a FDF/XFDF file, please refer to functions pdf.PDFDoc.importFromFDF and pdf.PDFDoc.exportToFDF.Example:How to load the forms in a PDFimport com.foxit.sdk.pdf.interform.Form;...// Assuming PDFDoc doc has been loaded....Boolean hasForm = doc.hasForm();if(hasForm) Form form = new Form(doc);...How to count form fields and get the propertiesimport com.foxit.sdk.pdf.interform.Form;import com.foxit.sdk.pdf.interform.Control;import com.foxit.sdk.pdf.interform.Field;...// Assuming PDFDoc doc has been loaded....Form form = new Form(doc);String filter = ""; int nControlCount = form.getFieldCount(filter);for (int i=0; iHow to export the form data in a PDF to a XML fileimport com.foxit.sdk.pdf.interform.Form;...// Assuming PDFDoc doc has been loaded....Form form = new Form(doc);form.exportToXML("form.xml");...How to import form data from a XML fileimport com.foxit.sdk.pdf.interform.Form;...Form form = new Form(doc);form.importFromXML("form.xml");...How to get coordinates of a form fieldLoad PDF file by PDFDoc.Traverse the form fields of the PDFDoc to get the field object of form.Traverse the form controls of the field object to get the form control object.Get the related widget annotation object by form control.Call the GetRect of the widget annotation object to get the coordinate of the form.import com.foxit.sdk.common.Constants;import com.foxit.sdk.common.fxcrt.RectF;import com.foxit.sdk.PDFException;import com.foxit.sdk.common.Library;import com.foxit.sdk.pdf.annots.Widget;import com.foxit.sdk.pdf.interform.Control;import com.foxit.sdk.pdf.interform.Field;import com.foxit.sdk.pdf.interform.Form;import com.foxit.sdk.pdf.PDFDoc;...// Load a documentPDFDoc doc = new PDFDoc(input_file);int error_code = doc.load(null);if (error_code != Constants.e_ErrSuccess) { System.out.println("The Doc " + input_file + " Error: " + error_code); return;}if (!doc.hasForm()) return;Form form = new Form(doc); for (int i = 0; i if (field.isEmpty()) continue; for (int j = 0; j XFA FormXFA (XML Forms Architecture) forms are XML-based forms, wrapped inside a PDF. The XML Forms Architecture provides a template-based grammar and a set of processing rules that allow uses to build interactive forms.
2025-04-21