Table of Contents

Class PdfXfaDateTimeField

Namespace
Syncfusion.Pdf.Xfa
Assembly
Syncfusion.Pdf.Portable.dll

Represents the date time field of the XFA form.

public class PdfXfaDateTimeField : PdfXfaStyledField
Inheritance
PdfXfaDateTimeField
Inherited Members

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Constructors

PdfXfaDateTimeField(string, SizeF)

Initialize a new instance of the PdfXfaDateTimeField class.

public PdfXfaDateTimeField(string name, SizeF size)

Parameters

name string

Name of the field.

size SizeF

Size of the field.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

PdfXfaDateTimeField(string, float, float)

Initialize a new instance of the PdfXfaDateTimeField class.

public PdfXfaDateTimeField(string name, float width, float height)

Parameters

name string

Name of the field.

width float

Width of the field.

height float

Height of the field.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", 100, 30);
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", 100, 30)
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Properties

Caption

Gets or sets the caption of the field

public PdfXfaCaption Caption { get; set; }

Property Value

PdfXfaCaption

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set caption.
field.Caption.Text = "Date";  
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set caption.
field.Caption.Text = "Date"  
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

DatePattern

Gets or sets the date format

public PdfXfaDatePattern DatePattern { get; set; }

Property Value

PdfXfaDatePattern

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(200, 30));
//Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Date;
//Set date pattern.
field.DatePattern = PdfXfaDatePattern.Full;            
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(200, 30))
'Set the default value
field.Value = DateTime.Now
'Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Date
'Set date pattern.
field.DatePattern = PdfXfaDatePattern.Full            
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Format

Gets or sets the date time field format

public PdfXfaDateTimeFormat Format { get; set; }

Property Value

PdfXfaDateTimeFormat

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time;
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Padding

Gets or sets the padding

public PdfPaddings Padding { get; set; }

Property Value

PdfPaddings

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set paddings.
field.Padding.All = 2;
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set paddings.
field.Padding.All = 2
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

RequireValidation

Gets or sets the validations

public bool RequireValidation { get; set; }

Property Value

bool

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time;
//Set time pattern.
field.TimePattern = PdfXfaTimePattern.Long;
//Set the default value
field.Value = DateTime.Now;
//Set validation.
field.RequireValidation = true;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time
//Set time pattern.
field.TimePattern = PdfXfaTimePattern.Long
'Set the default value
field.Value = DateTime.Now
'Set validation.
field.RequireValidation = True
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Remarks

The validations doesn't supports to the dateTime type

TimePattern

Gets or sets the time patterns

public PdfXfaTimePattern TimePattern { get; set; }

Property Value

PdfXfaTimePattern

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time;
//Set time pattern.
field.TimePattern = PdfXfaTimePattern.Long;
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the format of the date time field.
field.Format = PdfXfaDateTimeFormat.Time
//Set time pattern.
field.TimePattern = PdfXfaTimePattern.Long
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Value

Gets or Sets the value of date time field

public DateTime Value { get; set; }

Property Value

DateTime

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Methods

Clone()

Creates a new object that is a copy of the current instance.

public object Clone()

Returns

object

The copy of the new object for this instance.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA Field
PdfXfaDateTimeField field = new PdfXfaDateTimeField("dateTime1", new SizeF(100, 30));
//Set the default value
field.Value = DateTime.Now;
//Add the field to the form
form.Fields.Add(field);
//Clone the date time field.
xfaForm.Fields.Add(field.Clone() as PdfXfaDateTimeField);  
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA Field
Dim field As New PdfXfaDateTimeField("dateTime1", New SizeF(100, 30))
'Set the default value
field.Value = DateTime.Now
'Add the field to the form
form.Fields.Add(field)
'Clone the date time field.
xfaForm.Fields.Add(TryCast(field.Clone(), PdfXfaDateTimeField)) 
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()