Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4504,6 +4504,94 @@ document.Close(True)

You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Forms/Export_checkbox_values/.NET).

## Add a date field to a PDF form

This section explains how to add a date text box field to a PDF form using the Syncfusion PDF library. The field is initialized with a sample date and uses JavaScript-based formatting to enforce the date format, validate input, and automatically format user entries.

The following code example illustrates how to add a date field to a PDF form.

{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Forms/Add-a-date-field-to-a-PDF/.NET/Add-a-date-field-to-a-PDF/Program.cs" %}

using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

// Create a new PDF document
using (PdfDocument pdfDocument = new PdfDocument())
{
// Add a new page to the PDF document
PdfPage pdfPage = pdfDocument.Pages.Add();
// Create a text box field for entering the name
PdfTextBoxField nameField = new PdfTextBoxField(pdfPage, "DateField");
nameField.Bounds = new RectangleF(10, 40, 70, 20);
nameField.ToolTip = "Date";
nameField.Text = "12/01/1995";
//Set the scriptAction to submitButton
nameField.Actions.KeyPressed = new PdfJavaScriptAction("AFDate_KeystrokeEx(\"mm/dd/yyyy\")");
nameField.Actions.Format = new PdfJavaScriptAction("AFDate_FormatEx(\"mm/dd/yyyy\")");
nameField.Actions.Validate = new PdfJavaScriptAction("AFDate_Validate(\"mm/dd/yyyy\")");
// Add the field to the form
pdfDocument.Form.Fields.Add(nameField);
// Save the PDF document
pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}

using System.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

// Create a new PDF document
using (PdfDocument pdfDocument = new PdfDocument())
{
// Add a new page to the PDF document
PdfPage pdfPage = pdfDocument.Pages.Add();
// Create a text box field for entering the name
PdfTextBoxField nameField = new PdfTextBoxField(pdfPage, "DateField");
nameField.Bounds = new RectangleF(10, 40, 70, 20);
nameField.ToolTip = "Date";
nameField.Text = "12/01/1995";
//Set the scriptAction to submitButton
nameField.Actions.KeyPressed = new PdfJavaScriptAction("AFDate_KeystrokeEx(\"mm/dd/yyyy\")");
nameField.Actions.Format = new PdfJavaScriptAction("AFDate_FormatEx(\"mm/dd/yyyy\")");
nameField.Actions.Validate = new PdfJavaScriptAction("AFDate_Validate(\"mm/dd/yyyy\")");
// Add the field to the form
pdfDocument.Form.Fields.Add(nameField);
// Save the PDF document
pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
{% endhighlight %}
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

Imports System.Drawing
Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Interactive

' Create a new PDF document
Using pdfDocument As New PdfDocument()
' Add a new page to the PDF document
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
' Create a text box field for entering the name
Dim nameField As New PdfTextBoxField(pdfPage, "DateField")
nameField.Bounds = New RectangleF(10, 40, 70, 20)
nameField.ToolTip = "Date"
nameField.Text = "12/01/1995"
' Set the scriptAction to submitButton
nameField.Actions.KeyPressed = New PdfJavaScriptAction("AFDate_KeystrokeEx(\"mm/dd/yyyy\")")
nameField.Actions.Format = New PdfJavaScriptAction("AFDate_FormatEx(\"mm/dd/yyyy\")")
nameField.Actions.Validate = New PdfJavaScriptAction("AFDate_Validate(\"mm/dd/yyyy\")")
' Add the field to the form
pdfDocument.Form.Fields.Add(nameField)
' Save the PDF document
pdfDocument.Save(Path.GetFullPath("Output/Output.pdf"))
End Using
{% endhighlight %}
{% endtabs %}

You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Forms/Add-a-date-field-to-a-PDF/.NET).

## Unified radio button selection

The essential<sup>&reg;</sup> PDF allows radio buttons within the same group that have identical export values to be selected or deselected simultaneously.
Expand Down