mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
JS -- Plug PageOpen and PageClose actions
This commit is contained in:
parent
ed3758f84d
commit
6523f8880b
5 changed files with 172 additions and 16 deletions
|
@ -91,6 +91,7 @@ class Doc extends PDFObject {
|
|||
this._zoom = data.zoom || 100;
|
||||
this._actions = createActionsMap(data.actions);
|
||||
this._globalEval = data.globalEval;
|
||||
this._pageActions = new Map();
|
||||
}
|
||||
|
||||
_dispatchDocEvent(name) {
|
||||
|
@ -114,22 +115,28 @@ class Doc extends PDFObject {
|
|||
}
|
||||
}
|
||||
|
||||
_dispatchPageEvent(name, action, pageNumber) {
|
||||
_dispatchPageEvent(name, actions, pageNumber) {
|
||||
if (name === "PageOpen") {
|
||||
if (!this._pageActions.has(pageNumber)) {
|
||||
this._pageActions.set(pageNumber, createActionsMap(actions));
|
||||
}
|
||||
this._pageNum = pageNumber - 1;
|
||||
}
|
||||
|
||||
this._globalEval(action);
|
||||
actions = this._pageActions.get(pageNumber)?.get(name);
|
||||
if (actions) {
|
||||
for (const action of actions) {
|
||||
this._globalEval(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_runActions(name) {
|
||||
if (!this._actions.has(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const actions = this._actions.get(name);
|
||||
for (const action of actions) {
|
||||
this._globalEval(action);
|
||||
if (actions) {
|
||||
for (const action of actions) {
|
||||
this._globalEval(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue