How to preserve Datepicker widget after document is saved

WebViewer Version:

8.9

Do you have an issue with a specific file(s)?

DatPickerWidgetAnnotation

Can you reproduce using one of our samples or online demos?

No

Are you using the WebViewer server?

No

Does the issue only happen on certain browsers?

No

Is your issue related to a front-end framework?

React

Is your issue related to annotations?

Yes

Please give a brief summary of your issue:
(Think of this as an email subject)

DatePickerWidgetAnnotation is converted to “text” from “date” when saved to PDF file.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Datepicker annotation’s element is converted into “text” from “date” when the PDF is saved and viewed again. See code snippet below.

// create datepicker
const flags = new Annotations.WidgetFlags(null);
flags.set('Required', true);
field = new Annotations.Forms.Field(annotName + Date.now() + index, {
    type: 'Tx',
    flags,
});
inputAnnot = new Annotations.DatePickerWidgetAnnotation(field, {});

// draw the annotation the viewer
annotationManager.addAnnotation(inputAnnot);
fieldManager.addField(field);
annotsToDraw.push(inputAnnot);

// save document
const doc = documentViewer.getDocument();
const xfdfString = await annotationManager.exportAnnotations();
const data = await doc.getFileData({xfdfString,});
const arr = new Uint8Array(data);
const blob = new Blob([arr], {type: ContentType.pdf,});

Annotation element during creation
image

Annotation element after loading saved document
image

Hi Adrian,

Please add the required date format options to the DateWidget annotation for it to be recognized as a DateWidget.

Here is an old forum post with some sample code:
https://pdfjs.community/t/custom-date-format-for-datepickerwidgetannotation/587/4

Please let me know if there are any issues.

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems Inc
www.pdftron.com