From bbd49bdac07688edcd2ae27f9e4bffda1dffb7b6 Mon Sep 17 00:00:00 2001 From: zboris12 <97102880+zboris12@users.noreply.github.com> Date: Thu, 23 Apr 2026 22:55:31 +0900 Subject: [PATCH] Added a solution of atob not found in Google Apps Script to README.md. --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index feac18f..62ee3e0 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,19 @@ function clearTimeout(timeoutID){ } // Simulate window for node-forge var window = globalThis; +// simulate atob for zgapdfsigner +function atob(base64String) { + // 1. Decode Base64 string into a byte array + var decoded = Utilities.base64Decode(base64String); + + // 2. Convert each byte to a string using its character code + // Since atob returns a "binary string", concatenate each element using String.fromCharCode + return decoded.map(function (byte) { + // Since Google Apps Script's bytes are signed (-128 to 127), correct them to the range of 0-255 + return String.fromCharCode(byte & 0xFF); + }).join(''); +}; + // Load pdf-lib eval(UrlFetchApp.fetch("https://unpkg.com/pdf-lib@1.17.1/dist/pdf-lib.min.js").getContentText()); // It is necessary for drawing text for signature.