mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
For text widgets, get the text from the AP stream instead of from the format callback (bug 1825002)
When fixing bug 1766987, I thought the field formatted value came from the result of the format callback: I was wrong. The format callback is ran but the value is unused (maybe it's useful to set some global vars... or it's just a bug in Acrobat). Anyway the value to display is the one rendered in the AP stream. The field value setter has been simplified and that fixes issue #16409.
This commit is contained in:
parent
5ae353cf4d
commit
177036e6ae
7 changed files with 93 additions and 35 deletions
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createActionsMap, FieldType, getFieldType } from "./common.js";
|
||||
import { createActionsMap, getFieldType } from "./common.js";
|
||||
import { Color } from "./color.js";
|
||||
import { PDFObject } from "./pdf_object.js";
|
||||
|
||||
|
@ -247,29 +247,15 @@ class Field extends PDFObject {
|
|||
return;
|
||||
}
|
||||
|
||||
if (value === "") {
|
||||
this._value = "";
|
||||
} else if (typeof value === "string") {
|
||||
switch (this._fieldType) {
|
||||
case FieldType.none: {
|
||||
this._originalValue = value;
|
||||
const _value = value.trim().replace(",", ".");
|
||||
this._value = !isNaN(_value) ? parseFloat(_value) : value;
|
||||
break;
|
||||
}
|
||||
case FieldType.number:
|
||||
case FieldType.percent: {
|
||||
const _value = value.trim().replace(",", ".");
|
||||
const number = parseFloat(_value);
|
||||
this._value = !isNaN(number) ? number : 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this._value = value;
|
||||
}
|
||||
} else {
|
||||
if (value === "" || typeof value !== "string") {
|
||||
this._originalValue = undefined;
|
||||
this._value = value;
|
||||
return;
|
||||
}
|
||||
|
||||
this._originalValue = value;
|
||||
const _value = value.trim().replace(",", ".");
|
||||
this._value = !isNaN(_value) ? parseFloat(_value) : value;
|
||||
}
|
||||
|
||||
_getValue() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue