We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Dynamic Timestamp Field

Hello. Currently evaluating Aspose PDF for .NET and not sure if possible to do what we would like easily.

We have staff that create PDFs with Adobe DC that has a “Dynamic stamp” feature which they use to automatically populate a date/time field that is updated when the PDF is opened.

I can see how I can generate something similar and add to the header or footer when creating / saving a PDF, but were are not looking to capture this value, but rather when the form is opened filled out. Is this possible? It looks like Adobe is creating some Javascript that is then triggered when the file is opened to update the field.

Thanks

@dlaskey

Thanks for evaluating our API.

You may add TextBoxField inside PDF and set its value to current date/time with JavaScriptAction at the time when PDF is opened. Please use following code snippet with Aspose.PDF for .NET in order to achieve your requirements. For your kind reference, an output PDF document is also attached.

Document pdfDocument = new Document();
pdfDocument.Pages.Add();
// Create a field
TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300));
textBoxField.PartialName = "textbox1";
textBoxField.Value = "Text Box";
// TextBoxField.Border = new Border(
Border border = new Border(textBoxField);
border.Width = 5;
border.Dash = new Dash(1, 1);
textBoxField.Border = border;
textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
// Add field to the document
pdfDocument.Form.Add(textBoxField, 1);
string JS = @"var w = this.getField('" + textBoxField.PartialName + "'); w.value = new Date();";
pdfDocument.OpenAction = new JavascriptAction(JS);
pdfDocument.Save(dataDir + "DynamicTimeStamp.pdf");

DynamicTimeStamp.pdf (2.2 KB)

Thank you so much. I will let you know how it works out. I am still having issues with the Temp License getting applied

@dlaskey

Thanks for your feedback.

Please take your time to test the scenario. In case you face any issue or need further assistance, please feel free to let us know.

1 Like

Thank you. This solution worked for me.

@dlaskey

Thanks for your kind feedback.

It is good to know that your requirement have been fulfilled by suggested approach. Please keep using our API and in case of any further assistance, please feel free to create new post.