From 209ac5ca579741082d043689d78ff2d6d5ac661c Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sat, 22 May 2021 15:09:43 +0200 Subject: [PATCH] XFA - Don't display images with a href --- src/core/xfa/template.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 2a7ed07a0..e1c836ca5 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -2248,24 +2248,25 @@ class Image extends StringObject { } [$toHTML]() { - const html = { - name: "img", - attributes: { - class: "xfaImage", - style: {}, - }, - }; - - if (this.href) { - html.attributes.src = new URL(this.href).href; - return html; + if (this.href || !this[$content]) { + // TODO: href can be a Name refering to an internal stream + // containing a picture. + // In general, we don't get remote data and use what we have + // in the pdf itself, so no picture for non null href. + return null; } if (this.transferEncoding === "base64") { const buffer = stringToBytes(atob(this[$content])); const blob = new Blob([buffer], { type: this.contentType }); - html.attributes.src = URL.createObjectURL(blob); - return html; + return { + name: "img", + attributes: { + class: "xfaImage", + style: {}, + src: URL.createObjectURL(blob), + }, + }; } return null;