mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Obtain the export values for choice widgets from the normal appearance
The down appearance (`D`) is optional and not available in the document from #12233, so the checkboxes are never saved/printed as checked because the checked appearance is based on the export value that is missing because the `D` entry is not available. Instead, we should use the normal appearance (`N`) since that one is required and therefore always available. Finally, the /Off appearance is optional according to section 12.7.4.2.3 of the specification, so that needs to be taken into account to match the specification and to fix reference test failures for the `annotation-button-widget-print` test. That is a file that doesn't specify an /Off appearance in the normal appearance dictionary.
This commit is contained in:
parent
1b82ad8fff
commit
a8efc0296b
2 changed files with 44 additions and 34 deletions
|
@ -1531,25 +1531,23 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||
return;
|
||||
}
|
||||
|
||||
const exportValueOptionsDict = customAppearance.get("D");
|
||||
if (!isDict(exportValueOptionsDict)) {
|
||||
const normalAppearance = customAppearance.get("N");
|
||||
if (!isDict(normalAppearance)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const exportValues = exportValueOptionsDict.getKeys();
|
||||
const hasCorrectOptionCount = exportValues.length === 2;
|
||||
if (!hasCorrectOptionCount) {
|
||||
const exportValues = normalAppearance.getKeys();
|
||||
if (!exportValues.includes("Off")) {
|
||||
// The /Off appearance is optional.
|
||||
exportValues.push("Off");
|
||||
}
|
||||
if (exportValues.length !== 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.data.exportValue =
|
||||
exportValues[0] === "Off" ? exportValues[1] : exportValues[0];
|
||||
|
||||
const normalAppearance = customAppearance.get("N");
|
||||
if (!isDict(normalAppearance)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.checkedAppearance = normalAppearance.get(this.data.exportValue);
|
||||
this.uncheckedAppearance = normalAppearance.get("Off") || null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue