From 5cc5d9be45975a36beae25e7a9ce9df1bc808ebf Mon Sep 17 00:00:00 2001 From: calixteman Date: Sun, 12 Apr 2026 13:40:13 +0200 Subject: [PATCH] [Debugger] Fix the content stream rendering when it's a ref to an array It can be verified in opening stepped.pdf (see #21089). --- src/core/internal_viewer_utils.js | 5 ++++- src/core/pdf_manager.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/internal_viewer_utils.js b/src/core/internal_viewer_utils.js index dcb48db7a..6fec7b5ce 100644 --- a/src/core/internal_viewer_utils.js +++ b/src/core/internal_viewer_utils.js @@ -316,7 +316,10 @@ const InternalViewerUtils = { }, getContentTokens(contentsVal, xref) { - const refs = Array.isArray(contentsVal) ? contentsVal : [contentsVal]; + // Contents may be a Ref to a stream, a direct array of Refs, or a Ref to + // an array of Refs. Resolve one level to detect the array case. + const resolvedVal = xref.fetchIfRef(contentsVal); + const refs = Array.isArray(resolvedVal) ? resolvedVal : [contentsVal]; const rawContents = []; const tokens = []; const rawBytesArr = []; diff --git a/src/core/pdf_manager.js b/src/core/pdf_manager.js index 9c47fcec2..b00b26b11 100644 --- a/src/core/pdf_manager.js +++ b/src/core/pdf_manager.js @@ -196,7 +196,7 @@ class NetworkPdfManager extends BasePdfManager { try { const value = obj[prop]; if (typeof value === "function") { - return value.apply(obj, args); + return await value.apply(obj, args); } return value; } catch (ex) {