Merge pull request #12481 from calixteman/issue_12475
Get urls if any in AA::D dictionary for pushbuttons
This commit is contained in:
commit
ff2631493e
@ -1905,12 +1905,16 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_processPushButton(params) {
|
_processPushButton(params) {
|
||||||
if (!params.dict.has("A") && !this.data.alternativeText) {
|
if (
|
||||||
|
!params.dict.has("A") &&
|
||||||
|
!params.dict.has("AA") &&
|
||||||
|
!this.data.alternativeText
|
||||||
|
) {
|
||||||
warn("Push buttons without action dictionaries are not supported");
|
warn("Push buttons without action dictionaries are not supported");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data.isTooltipOnly = !params.dict.has("A");
|
this.data.isTooltipOnly = !params.dict.has("A") && !params.dict.has("AA");
|
||||||
|
|
||||||
Catalog.parseDestDictionary({
|
Catalog.parseDestDictionary({
|
||||||
destDict: params.dict,
|
destDict: params.dict,
|
||||||
|
@ -1165,10 +1165,23 @@ class Catalog {
|
|||||||
let action = destDict.get("A"),
|
let action = destDict.get("A"),
|
||||||
url,
|
url,
|
||||||
dest;
|
dest;
|
||||||
if (!isDict(action) && destDict.has("Dest")) {
|
if (!isDict(action)) {
|
||||||
// A /Dest entry should *only* contain a Name or an Array, but some bad
|
if (destDict.has("Dest")) {
|
||||||
// PDF generators ignore that and treat it as an /A entry.
|
// A /Dest entry should *only* contain a Name or an Array, but some bad
|
||||||
action = destDict.get("Dest");
|
// PDF generators ignore that and treat it as an /A entry.
|
||||||
|
action = destDict.get("Dest");
|
||||||
|
} else {
|
||||||
|
action = destDict.get("AA");
|
||||||
|
if (isDict(action)) {
|
||||||
|
if (action.has("D")) {
|
||||||
|
// MouseDown
|
||||||
|
action = action.get("D");
|
||||||
|
} else if (action.has("U")) {
|
||||||
|
// MouseUp
|
||||||
|
action = action.get("U");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDict(action)) {
|
if (isDict(action)) {
|
||||||
|
@ -2658,6 +2658,63 @@ describe("annotation", function () {
|
|||||||
done();
|
done();
|
||||||
}, done.fail);
|
}, done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle URL in A dict in push buttons", function (done) {
|
||||||
|
const buttonWidgetRef = Ref.get(124, 0);
|
||||||
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
||||||
|
|
||||||
|
const actionDict = new Dict();
|
||||||
|
actionDict.set("S", Name.get("JavaScript"));
|
||||||
|
actionDict.set(
|
||||||
|
"JS",
|
||||||
|
"app.launchURL('https://developer.mozilla.org/en-US/', true)"
|
||||||
|
);
|
||||||
|
buttonWidgetDict.set("A", actionDict);
|
||||||
|
|
||||||
|
const xref = new XRefMock([
|
||||||
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
||||||
|
]);
|
||||||
|
|
||||||
|
AnnotationFactory.create(
|
||||||
|
xref,
|
||||||
|
buttonWidgetRef,
|
||||||
|
pdfManagerMock,
|
||||||
|
idFactoryMock
|
||||||
|
).then(({ data }) => {
|
||||||
|
expect(data.url).toEqual("https://developer.mozilla.org/en-US/");
|
||||||
|
done();
|
||||||
|
}, done.fail);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle URL in AA dict in push buttons", function (done) {
|
||||||
|
const buttonWidgetRef = Ref.get(124, 0);
|
||||||
|
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
|
||||||
|
|
||||||
|
// D stands for MouseDown
|
||||||
|
const dDict = new Dict();
|
||||||
|
dDict.set("S", Name.get("JavaScript"));
|
||||||
|
dDict.set(
|
||||||
|
"JS",
|
||||||
|
"app.launchURL('https://developer.mozilla.org/en-US/', true)"
|
||||||
|
);
|
||||||
|
const actionDict = new Dict();
|
||||||
|
actionDict.set("D", dDict);
|
||||||
|
buttonWidgetDict.set("AA", actionDict);
|
||||||
|
|
||||||
|
const xref = new XRefMock([
|
||||||
|
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
||||||
|
]);
|
||||||
|
|
||||||
|
AnnotationFactory.create(
|
||||||
|
xref,
|
||||||
|
buttonWidgetRef,
|
||||||
|
pdfManagerMock,
|
||||||
|
idFactoryMock
|
||||||
|
).then(({ data }) => {
|
||||||
|
expect(data.url).toEqual("https://developer.mozilla.org/en-US/");
|
||||||
|
done();
|
||||||
|
}, done.fail);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("ChoiceWidgetAnnotation", function () {
|
describe("ChoiceWidgetAnnotation", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user