Which product are you using?
PDF.js Express
PDF.js Express Version
Build:
‘NC8xMi8yMDIyfGI0OTc1YjFjZA==’
Core version:
‘8.4.0’
Full API:
false
UI version:
‘8.4.1’
WebViewer Server:
false
Detailed description of issue
I create a Listbox with
...} else if (annot.getCustomData("type") === "Listbox") {
if (annot.getCustomData("multiline") === "true") {
flags.set(instance.Annotations.WidgetFlags.MULTI_SELECT, true);
} else {
flags.set(instance.Annotations.WidgetFlags.MULTI_SELECT, false);
}
const font = new instance.Annotations.Font({ name: "Helvetica" });
var qselections = [];
var options = JSON.parse(annot.getCustomData("options"));
options.forEach((option) => {
qselections.push({ value: option });
});
field = new instance.Annotations.Forms.Field(annot.Id, {
type: "Ch",
options: qselections,
flags,
font,
});
annotField = new instance.Annotations.ListWidgetAnnotation(field);
instance.annotManager.addAnnotation(annotField); ...
On the field I add the following
field.addEventListener("commit", this.fieldChanged)
The event handler is:
fieldChanged = (value, annot) => {
var field = annot.getField();
...
There are two issue that I notice:
Issue 1 - when selecting one value in the Listbox the event handler method gets called two times.
Issue 2 - when selecting multiple values in the Listbox I expect to get an array of values. This does not happen and in the debug console I get the following error:
TypeError: z.replace is not a function
at da.ik.f7 (:2443:111)
at a.refresh (:527:360)
at oa.refresh (:1867:101)
at a.Ci (:527:161)
at oa.<anonymous> (:517:265)
at :677:8
at Array.forEach (<anonymous>)
at x.trigger (:676:530)
at HTMLSelectElement.<anonymous> (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:1870:271) {stack: 'TypeError: z.replace is not a function
at…ewer/lib/core/webviewer-core.min.js:1870:271)', message: 'z.replace is not a function'}
Uncaught Error Error: TypeError: z.replace is not a function
at ha (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:214:1)
at <anonymous> (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:677:69)
at x.trigger (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:676:530)
at <anonymous> (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:1870:271)
TypeError: z.replace is not a function
at da.ik.f7 (:2443:111)
at a.refresh (:527:360)
at oa.refresh (:1867:101)
at a.Ci (:527:161)
at a.Kb (:524:9)
at :2605:223
at Array.forEach (<anonymous>)
at f.ha.qa.Dm (:2597:255)
at f.ha.qa.SD.GK (:2605:206)
at f.ha.qa.SD.Kb (http://localhost:3000/webviewer/lib/core/webviewer-core.min.js:2605:120) {stack: 'TypeError: z.replace is not a function
at…ewer/lib/core/webviewer-core.min.js:2605:120)', message: 'z.replace is not a function'}
Expected behaviour
For Issue 1 - I expect the event handler to be called only once
For Issue 2 - I expect the event handler to return an array of selected values.
Does your issue happen with every document, or just one?
Not specific to any PDF
Link to document
Not specific to any PDF