Having trouble getting help?
Contact Support
Contact Support
How to add the date to the signature text
6 Dec 20242 minutes to read
To add a date with the signature text in Syncfusion® PDF Viewer, use the updateFormFieldsValue()
method. Add a signature field to a PDF document and get the signature field in a PDF using the retrieveFormFields()
method and store it in a variable. Modify the value of the signature field and get the current date. Use the Date()
method to get the current date and format it as desired.
Update the signature field in a PDF using the updateFormFieldsValue()
method and pass the modified signature field as a parameter.
```html
<div>
<div style="width:100%;height:600px">
<button type="button" onclick="signatureWithDate()">Add Signature with the time</button>
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf").Render()
</div>
</div>
<script>
function signatureWithDate() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
var formFields = viewer.retrieveFormFields();
formFields[0].signatureType = 'Type';
formFields[0].value = 'Syncfusion \n' + new Date();
viewer.updateFormFieldsValue(formFields[0]);
}
</script>
```
```html
<div>
<div style="width:100%;height:600px">
<button type="button" onclick="signatureWithDate()">Add Signature with the time</button>
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/Home/")).DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").Render()
</div>
</div>
<script>
function signatureWithDate() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
var formFields = viewer.retrieveFormFields();
formFields[0].signatureType = 'Type';
formFields[0].value = 'Syncfusion \n' + new Date();
viewer.updateFormFieldsValue(formFields[0]);
}
</script>
```