diff --git a/web/app.js b/web/app.js index 0e6b6ad9276c6..058d31ce9bbcf 100644 --- a/web/app.js +++ b/web/app.js @@ -3266,9 +3266,14 @@ function webViewerKeyDown(evt) { } function webViewerPostMessage(evt) { - if (evt && evt.data && typeof evt.data === "string") { + if (evt && evt.data) { try { - const { action, data } = JSON.parse(evt.data); + let action, data; + if (typeof evt.data === "string") { + ({ action, data } = JSON.parse(evt.data)); + } else { + ({ action, data } = evt.data); + } switch (action) { case "openBase64File": PDFViewerApplication.open({ @@ -3276,6 +3281,12 @@ function webViewerPostMessage(evt) { originalUrl: data.name, }); break; + case "openArrayBufferFile": + PDFViewerApplication.open({ + data: new Uint8Array(data.data), + originalUrl: data.name, + }); + break; } } catch (ex) { console.error(`webViewerPostMessage: ${ex}`);