Switch the order of the "display"/"print" intent handling in XfaLayerBuilder.render
Given that the "print"-intent is special, and that we should always fallback to the "display"-intent, let's ensure that the code actually reflects that. Also, ensure that the method always returns a `Promise` since that's what the documentation says.
This commit is contained in:
parent
eb94d71b71
commit
45c1390c42
@ -43,56 +43,55 @@ class XfaLayerBuilder {
|
|||||||
* annotations is complete.
|
* annotations is complete.
|
||||||
*/
|
*/
|
||||||
render(viewport, intent = "display") {
|
render(viewport, intent = "display") {
|
||||||
if (intent === "display") {
|
if (intent === "print") {
|
||||||
return this.pdfPage
|
viewport.dontFlip = true;
|
||||||
.getXfa()
|
const parameters = {
|
||||||
.then(xfa => {
|
viewport,
|
||||||
if (this._cancelled) {
|
div: this.div,
|
||||||
return;
|
xfa: this.xfaHtml,
|
||||||
}
|
page: null,
|
||||||
const parameters = {
|
annotationStorage: this.annotationStorage,
|
||||||
viewport: viewport.clone({ dontFlip: true }),
|
intent,
|
||||||
div: this.div,
|
};
|
||||||
xfa,
|
|
||||||
page: this.pdfPage,
|
|
||||||
annotationStorage: this.annotationStorage,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.div) {
|
// Create an xfa layer div and render the form
|
||||||
XfaLayer.update(parameters);
|
const div = document.createElement("div");
|
||||||
} else {
|
this.pageDiv.appendChild(div);
|
||||||
// Create an xfa layer div and render the form
|
parameters.div = div;
|
||||||
this.div = document.createElement("div");
|
|
||||||
this.pageDiv.appendChild(this.div);
|
|
||||||
parameters.div = this.div;
|
|
||||||
|
|
||||||
XfaLayer.render(parameters);
|
XfaLayer.render(parameters);
|
||||||
}
|
return Promise.resolve();
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// intent === "print".
|
// intent === "display"
|
||||||
viewport.dontFlip = true;
|
return this.pdfPage
|
||||||
const parameters = {
|
.getXfa()
|
||||||
viewport,
|
.then(xfa => {
|
||||||
div: this.div,
|
if (this._cancelled) {
|
||||||
xfa: this.xfaHtml,
|
return;
|
||||||
page: null,
|
}
|
||||||
annotationStorage: this.annotationStorage,
|
const parameters = {
|
||||||
intent,
|
viewport: viewport.clone({ dontFlip: true }),
|
||||||
};
|
div: this.div,
|
||||||
|
xfa,
|
||||||
|
page: this.pdfPage,
|
||||||
|
annotationStorage: this.annotationStorage,
|
||||||
|
};
|
||||||
|
|
||||||
// Create an xfa layer div and render the form
|
if (this.div) {
|
||||||
const div = document.createElement("div");
|
XfaLayer.update(parameters);
|
||||||
this.pageDiv.appendChild(div);
|
} else {
|
||||||
parameters.div = div;
|
// Create an xfa layer div and render the form
|
||||||
|
this.div = document.createElement("div");
|
||||||
|
this.pageDiv.appendChild(this.div);
|
||||||
|
parameters.div = this.div;
|
||||||
|
|
||||||
XfaLayer.render(parameters);
|
XfaLayer.render(parameters);
|
||||||
|
}
|
||||||
return null;
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user