Hi,Support:
Does the API support adding a datetime text element on pdf page and the added datetime text element can auto-update as the OS current date and time?
If so,how to reach it on VB.net?
Thanks for your help.
Can you clarify what you mean by element? Are you referring to a field?
Here is some code example in C#
private void Logic()
{
var doc = new Document();
var page = doc.Pages.Add();
// Create a date field
DateField dateField = new DateField(page, new Aspose.Pdf.Rectangle(100, 700, 450, 800));
dateField.PartialName = "dateField1";
dateField.Value = DateTime.Today;
// Create a Border
var border = new Border(dateField);
border.Width = 5;
border.Dash = new Dash(1, 1);
dateField.Border = border;
dateField.Color = Color.Red;
// Add field to the document
doc.Form.Add(dateField, 1);
// JS cumstom action
string JS = @"var w = this.getField('" + dateField.PartialName + "'); w.value = new Date();";
doc.OpenAction = new JavascriptAction(JS);
doc.Save($"{PartialPath}_output.pdf");
}
Here is a translation to VB(not a VB developer)
Private Sub Logic()
Dim doc As New Document()
Dim page As Page = doc.Pages.Add()
' Create a date field
Dim dateField As New DateField(page, New Aspose.Pdf.Rectangle(100, 700, 450, 800))
dateField.PartialName = "dateField1"
dateField.Value = DateTime.Today
' Create a Border
Dim border As New Border(dateField)
border.Width = 5
border.Dash = New Dash(1, 1)
dateField.Border = border
dateField.Color = Color.Red
' Add field to the document
doc.Form.Add(dateField, 1)
' JS cumstom action
Dim JS As String = "var w = this.getField('" & dateField.PartialName & "'); w.value = new Date();"
doc.OpenAction = New JavascriptAction(JS)
doc.Save($"{PartialPath}_output.pdf")
End Sub
Yes, The element is a data field that can be auto-updated whiling the document is loaded.
And I want to know whether the data field added by the above codes can be auto-updated to the OS current date and time?
You can add to the current code a custom Javascript action:
I edited the code above. You can modify the javascript to the format you want.
Thanks for your help.
And Else, what version of the API supports DateField feature? I use v21.4, and it does’n support DateField feature, therefore, I did not get the try result.