mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Make sure WillPrint ran before starting printing
This commit is contained in:
parent
7ae5a0fef7
commit
8439e11160
4 changed files with 58 additions and 20 deletions
|
@ -16,6 +16,7 @@
|
|||
import { createActionsMap } from "./common.js";
|
||||
import { PDFObject } from "./pdf_object.js";
|
||||
import { PrintParams } from "./print_params.js";
|
||||
import { serializeError } from "./app_utils.js";
|
||||
import { ZoomType } from "./constants.js";
|
||||
|
||||
const DOC_EXTERNAL = false;
|
||||
|
@ -126,20 +127,29 @@ class Doc extends PDFObject {
|
|||
}
|
||||
|
||||
_dispatchDocEvent(name) {
|
||||
if (name === "Open") {
|
||||
this._disableSaving = true;
|
||||
this._runActions("OpenAction");
|
||||
this._disableSaving = false;
|
||||
} else if (name === "WillPrint") {
|
||||
this._disablePrinting = true;
|
||||
this._runActions(name);
|
||||
this._disablePrinting = false;
|
||||
} else if (name === "WillSave") {
|
||||
this._disableSaving = true;
|
||||
this._runActions(name);
|
||||
this._disableSaving = false;
|
||||
} else {
|
||||
this._runActions(name);
|
||||
switch (name) {
|
||||
case "Open":
|
||||
this._disableSaving = true;
|
||||
this._runActions("OpenAction");
|
||||
this._disableSaving = false;
|
||||
break;
|
||||
case "WillPrint":
|
||||
this._disablePrinting = true;
|
||||
try {
|
||||
this._runActions(name);
|
||||
} catch (error) {
|
||||
this._send(serializeError(error));
|
||||
}
|
||||
this._send({ command: "WillPrintFinished" });
|
||||
this._disablePrinting = false;
|
||||
break;
|
||||
case "WillSave":
|
||||
this._disableSaving = true;
|
||||
this._runActions(name);
|
||||
this._disableSaving = false;
|
||||
break;
|
||||
default:
|
||||
this._runActions(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue