Which product are you using?
PDF.js Express
PDF.js Express Version
Detailed description of issue
I’m create a annotation with:
annotField = new instance.Annotations.DatePickerWidgetAnnotation
This field works fine and shows the date selection.
I then store the annotation/field into my database via:
var xfdf = await annotManager.exportAnnotations({
annotList: annots,
widgets: true,
links: true,
fields: true,
});
This is the xfdf file:
<?xml version="1.0" encoding="UTF-8" ?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<pdf-info xmlns="http://www.pdftron.com/pdfinfo" version="2" import-version="4">
<ffield type="Tx" name="2b555f1a-6cd1-d501-c1e0-89a4aef99acf" flags="Required">
<font name="Helvetica"/>
</ffield>
<widget field="2b555f1a-6cd1-d501-c1e0-89a4aef99acf" modified-date="D:20220617114011-07'00'" page="1">
<rect x1="29.453" x2="154.252" y1="734.093" y2="759.053"/>
<border width="0" style="null">
<color a="0"/>
</border>
<trn-custom-data bytes="{"teams":"[{\"id\":7}]","text":"Todays Date","sort_index":"1","required":"true","defaultchecked":"false","defaulttoday":"true","groupname":"","options":"[]","type":"Date"}"/>
</widget>
</pdf-info>
<fields>
<field name="2b555f1a-6cd1-d501-c1e0-89a4aef99acf">
<value/>
</field>
</fields>
<annots>
<freetext page="0" rect="29.453,734.093,154.252,759.053" color="#E6FAFF" flags="print" name="2b555f1a-6cd1-d501-c1e0-89a4aef99acf" title="Brooklyn Collins" subject="FreeText" date="D:20220617092925-07'00'" creationdate="D:20220617092912-07'00'" TextColor="#000000" FontSize="7.487942122186496">
<trn-custom-data bytes="{"type":"Date","trn-wrapped-text-lines":"[\"Date \"]","teams":"[{\"id\":7}]","required":"true","text":"Todays Date","groupname":"","multiline":"false","defaultchecked":"false","defaulttoday":"true","options":"[]"}"/>
<contents>Date</contents>
<contents-richtext>
<body>
<p>
<span style="color:#000000">Date</span>
<span/>
</p>
</body>
</contents-richtext>
<defaultappearance>0 0.8 1 rg /Helvetica 7.487942122186496 Tf</defaultappearance>
<defaultstyle>font: Helvetica 7.487942122186496pt; text-align: center; text-vertical-align: top; color: #000000</defaultstyle>
</freetext>
</annots>
</xfdf>
I then import the xfdf with :
annotManager.importAnnotations(dbAnnot.annotation);
var annotations = annotManager.getAnnotationsList();
annotations.forEach((annotation) => {
if (annotation.Subject === "Widget" && annotation.getCustomData("type") !== "") {
var field = fieldManager.getField(annotation.fieldName);
if (annotation.getCustomData("type") === "Date") {
var widget = field.widgets[0];
widget.getDatePicker().show(); // open date picker widget
annotation.refreshDatePicker();
}
My code fails with:
widget.getDatePicker is not a function
The imported field does not know it’s a DatePickerWidgetAnnotation.
How do I import or set this field so that its a DatePickerWidgetAnnotation widget?
Expected behavior
{Provide a screenshot or description of the expected behaviour}
I expected after import that the field would be a DatePickerWidgetAnnotation and allow me to select a date with a pulldown.
Does your issue happen with every document, or just one?
All Documents
Link to document
Any PDF
Code snippet
See above
Thank-you in advance for your help!