1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +02:00

Merge pull request #13437 from calixteman/xfa_mv_root

XFA - Move the fake HTML representation of XFA from the worker to the main thread
This commit is contained in:
calixteman 2021-05-31 10:14:15 +02:00 committed by GitHub
commit 8c53bf8647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 32 deletions

View file

@ -22,18 +22,35 @@ class XFAFactory {
try {
this.root = new XFAParser().parse(XFAFactory._createDocument(data));
this.form = new Binder(this.root).bind();
this.pages = this.form[$toHTML]();
this._createPages();
} catch (e) {
console.log(e);
}
}
getPage(pageIndex) {
return this.pages.children[pageIndex];
_createPages() {
this.pages = this.form[$toHTML]();
this.dims = this.pages.children.map(c => {
const { width, height } = c.attributes.style;
return [0, 0, parseInt(width), parseInt(height)];
});
}
getBoundingBox(pageIndex) {
return this.dims[pageIndex];
}
get numberPages() {
return this.pages.children.length;
return this.dims.length;
}
getPages() {
if (!this.pages) {
this._createPages();
}
const pages = this.pages;
this.pages = null;
return pages;
}
static _createDocument(data) {