From 04573d2dc8c94370df117c45694beea702b880db Mon Sep 17 00:00:00 2001
From: Calixte Denizet <calixte.denizet@gmail.com>
Date: Sat, 3 Jul 2021 12:59:42 +0200
Subject: [PATCH] XFA - Disable xfa rendering for XFAF pdfs   - we'll implement
 XFAF support later.

---
 src/core/catalog.js  | 12 ++++++++++++
 src/core/document.js |  1 +
 2 files changed, 13 insertions(+)

diff --git a/src/core/catalog.js b/src/core/catalog.js
index 6c768e856..417545f70 100644
--- a/src/core/catalog.js
+++ b/src/core/catalog.js
@@ -86,6 +86,18 @@ class Catalog {
     return shadow(this, "version", version.name);
   }
 
+  /**
+   * @type {boolean} `true` for pure XFA documents,
+   *   `false` for XFA Foreground documents.
+   */
+  get needsRendering() {
+    const needsRendering = this._catDict.get("NeedsRendering");
+    if (!isBool(needsRendering)) {
+      return shadow(this, "needsRendering", false);
+    }
+    return shadow(this, "needsRendering", needsRendering);
+  }
+
   get collection() {
     let collection = null;
     try {
diff --git a/src/core/document.js b/src/core/document.js
index c9ced6ca2..1d7c70a7b 100644
--- a/src/core/document.js
+++ b/src/core/document.js
@@ -849,6 +849,7 @@ class PDFDocument {
   get xfaFactory() {
     if (
       this.pdfManager.enableXfa &&
+      this.catalog.needsRendering &&
       this.formInfo.hasXfa &&
       !this.formInfo.hasAcroForm
     ) {