Skip to content

Commit

Permalink
Add openArrayBufferFile postMessage support
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Feb 3, 2025
1 parent cd981d7 commit 191387d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3096,16 +3096,27 @@ function onKeyDown(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({
data: atob(data.data),
originalUrl: data.name,
});
break;
case "openArrayBufferFile":
PDFViewerApplication.open({
data: new Uint8Array(data.data),
originalUrl: data.name,
});
break;
}
} catch (ex) {
console.error(`webViewerPostMessage: ${ex}`);
Expand Down

0 comments on commit 191387d

Please sign in to comment.