1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

AcroForm: Add support for ResetForm action

- it aims to fix #12721.
  - Thanks to PR #14023, we've now the fieldObjects in the annotation layer so we can easily map fields names on their id if needed.
  - Reset values in the storage, in the JS sandbox and in the visible html elements.
This commit is contained in:
Calixte Denizet 2021-09-26 21:04:11 +02:00
parent db7c91e7b1
commit aecbd7cd89
7 changed files with 302 additions and 15 deletions

View file

@ -1328,6 +1328,20 @@ class Catalog {
const actionName = actionType.name;
switch (actionName) {
case "ResetForm":
const flags = action.get("Flags");
const include = ((isNum(flags) ? flags : 0) & 1) === 0;
const fields = [];
const refs = [];
for (const obj of action.get("Fields") || []) {
if (isRef(obj)) {
refs.push(obj.toString());
} else if (isString(obj)) {
fields.push(stringToPDFString(obj));
}
}
resultObj.resetForm = { fields, refs, include };
break;
case "URI":
url = action.get("URI");
if (url instanceof Name) {
@ -1405,11 +1419,7 @@ class Catalog {
}
/* falls through */
default:
if (
actionName === "JavaScript" ||
actionName === "ResetForm" ||
actionName === "SubmitForm"
) {
if (actionName === "JavaScript" || actionName === "SubmitForm") {
// Don't bother the user with a warning for actions that require
// scripting support, since those will be handled separately.
break;