1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

XFA - Implement aspect property on image element

- it aims to fix issue #13634;
  - move some img-related functions in test/drivers.js in order to have images in xfa reftests.
This commit is contained in:
Calixte Denizet 2021-06-27 17:17:44 +02:00
parent ff3a5382ee
commit 71d17b0cc4
5 changed files with 91 additions and 44 deletions

View file

@ -2829,11 +2829,38 @@ class Image extends StringObject {
if (this.transferEncoding === "base64") {
const buffer = stringToBytes(atob(this[$content]));
const blob = new Blob([buffer], { type: this.contentType });
let style;
switch (this.aspect) {
case "fit":
case "actual":
// TODO: check what to do with actual.
// Normally we should return {auto, auto} for it but
// it implies some wrong rendering (see xfa_bug1716816.pdf).
break;
case "height":
style = {
width: "auto",
height: "100%",
};
break;
case "none":
style = {
width: "100%",
height: "100%",
};
break;
case "width":
style = {
width: "100%",
height: "auto",
};
break;
}
return HTMLResult.success({
name: "img",
attributes: {
class: ["xfaImage"],
style: {},
style,
src: URL.createObjectURL(blob),
},
});