mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
XFA - Move the fake HTML representation of XFA from the worker to the main thread
- the only goal of this patch is to be able to get synchronously the fake html when printing from firefox: - in order to print we need to inject some html in beforeprint callback but we cannot block in waiting for all the pages. - from a memory point of view: it doesn't change anything since the fake HTML is deleted in the worker; - this way we don't break any assumptions.
This commit is contained in:
parent
9478d2f064
commit
45c3f00a27
5 changed files with 50 additions and 32 deletions
|
@ -695,7 +695,15 @@ class PDFDocumentProxy {
|
|||
* @type {boolean} True if only XFA form.
|
||||
*/
|
||||
get isPureXfa() {
|
||||
return this._pdfInfo.isPureXfa;
|
||||
return !!this._transport._htmlForXfa;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Object | null} An object representing a HTML tree structure
|
||||
* to render the XFA, or `null` when no XFA form exists.
|
||||
*/
|
||||
get allXfaHtml() {
|
||||
return this._transport._htmlForXfa;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1255,8 +1263,8 @@ class PDFPageProxy {
|
|||
* are {Object} with a name, attributes (class, style, ...), value and
|
||||
* children, very similar to a HTML DOM tree), or `null` if no XFA exists.
|
||||
*/
|
||||
getXfa() {
|
||||
return (this._xfaPromise ||= this._transport.getPageXfa(this._pageIndex));
|
||||
async getXfa() {
|
||||
return this._transport._htmlForXfa?.children[this._pageIndex] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1552,7 +1560,6 @@ class PDFPageProxy {
|
|||
this.objs.clear();
|
||||
this._annotationsPromise = null;
|
||||
this._jsActionsPromise = null;
|
||||
this._xfaPromise = null;
|
||||
this._structTreePromise = null;
|
||||
this.pendingCleanup = false;
|
||||
return Promise.all(waitOn);
|
||||
|
@ -1588,7 +1595,6 @@ class PDFPageProxy {
|
|||
this.objs.clear();
|
||||
this._annotationsPromise = null;
|
||||
this._jsActionsPromise = null;
|
||||
this._xfaPromise = null;
|
||||
this._structTreePromise = null;
|
||||
if (resetStats && this._stats) {
|
||||
this._stats = new StatTimer();
|
||||
|
@ -2456,6 +2462,8 @@ class WorkerTransport {
|
|||
|
||||
messageHandler.on("GetDoc", ({ pdfInfo }) => {
|
||||
this._numPages = pdfInfo.numPages;
|
||||
this._htmlForXfa = pdfInfo.htmlForXfa;
|
||||
delete pdfInfo.htmlForXfa;
|
||||
loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
|
||||
});
|
||||
|
||||
|
@ -2812,12 +2820,6 @@ class WorkerTransport {
|
|||
});
|
||||
}
|
||||
|
||||
getPageXfa(pageIndex) {
|
||||
return this.messageHandler.sendWithPromise("GetPageXfa", {
|
||||
pageIndex,
|
||||
});
|
||||
}
|
||||
|
||||
getStructTree(pageIndex) {
|
||||
return this.messageHandler.sendWithPromise("GetStructTree", {
|
||||
pageIndex,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue