https://bugs.kde.org/show_bug.cgi?id=526421
Bug ID: 526421
Summary: Field.defaultValue returns undefined for fields
without assigning it to Field.value stores the literal
string "undefined"
Classification: Applications
Product: okular
Version First 25.04.2
Reported In:
Platform: Debian stable
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: PDF backend
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Okular runs the calculation scripts of the Kanton Zürich corporate tax return
("Formular 500", an Adobe InDesign/Acrobat AcroForm with document-level
JavaScript),
but the computed total fields end up containing the strings "undefined" and
"NaN"
instead of numbers. The same form calculates correctly in Acrobat and in pdf.js
(Firefox, tested with pdf.js 6.3).
STEPS TO REPRODUCE
1. Download the blank form: "Formular 500 – Steuererklärung für
Kapitalgesellschaften,
Genossenschaften und ausl. Personengesamtheiten 2025", Kanton Zürich,
Steueramt
(PDF metadata: Creator "Adobe InDesign CS3 (5.0.2)", Producer "Adobe PDF
Library 8.0",
Keywords "Version 001", ModDate 2024-12-05, encrypted AES, user password
empty).
2. Open in Okular, click "Show Forms".
3. Type a number (e.g. 1630) into the first Reingewinn field on page 1
(field a.gewinn.ss.0, "Staatssteuer" column), press Tab.
4. Look at the total fields, e.g. a.gewinn.ss.16 (line 16, "Total
Aufrechnungen")
and a.gewinn.ss.25 / .27 / .29, or save the file and inspect /V of those
fields.
OBSERVED RESULT
The read-only total fields contain the string "undefined"; some downstream
fields
contain "NaN" (they do arithmetic on "undefined"). From a file saved by Okular:
a.gewinn.ss.16 = "undefined" a.gewinn.ss.16_bs = "undefined"
a.gewinn.ss.24 = "undefined" a.gewinn.ss.25 = "undefined"
a.gewinn.ss.27 = "undefined" a.gewinn.ss.29 = "undefined"
b.gewinn.2/12/13 = "undefined" c.ek.ss.betrag.6/16 = "undefined"
c.ek.ss.betrag.15 = "NaN" c.ek.ss.betrag.17 = "NaN"
EXPECTED RESULT
Totals are numeric, as in Acrobat and pdf.js (e.g. 12345 + 2500 -> 14845).
ANALYSIS
The form's calculation is driven by a hidden field "calc.actions" whose /C
action
calls berech_head(); berech_p1(); berech_p2(); (document-level script
"berechnung").
berech_p1() contains code of this shape:
if (this.getField("a.gewinn.ss.0").value == "" && ... all inputs empty ...) {
this.getField("a.gewinn.ss.16").value =
this.getField("a.gewinn.ss.16").defaultValue;
...
} else {
this.getField("a.gewinn.ss.16").value = add_1_ss; // numeric sum
...
}
None of the fields in this form have a /DV entry. Acrobat (and pdf.js) return
"" for
Field.defaultValue in that case. Okular apparently returns JS undefined, and
assigning undefined to Field.value is stored as the string "undefined" rather
than
clearing the field. Two things would fix this independently:
(a) Field.defaultValue should return "" (empty string) when /DV is absent
(Acrobat JS API reference: defaultValue is a string).
(b) Field.value setter should treat undefined/null as "" rather than
stringifying it.
The form also uses comparisons of the form
field.value == field.defaultValue
throughout (also in "werte_bs()" which copies the Staatssteuer column into the
Bundessteuer column), so (a) affects more than the totals.
Other API used by this form, in case it matters for triage: event.targetName,
event.rc, event.willCommit, event.change, event.fieldFull, field.valueAsString,
field.display / display.hidden, field.fillColor, field.setFocus(),
util.printf("%,0.0f", ...), app.runtimeHighlight, this.getOCGs().
ENVIRONMENT
Okular 25.04.2, Debian GNU/Linux 13 (trixie) 13 (x86_64)
RELATED
A separate issue about the same form causing runaway appearance-stream
generation
(9 GiB RSS, 24 MB incremental save) is filed against Poppler
--
You are receiving this mail because:
You are watching all bug changes.