Added a solution of atob not found in Google Apps Script to README.md.

main
zboris12 2026-04-23 22:55:31 +09:00 committed by GitHub
parent 7686f4e33a
commit bbd49bdac0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -76,6 +76,19 @@ function clearTimeout(timeoutID){
} }
// Simulate window for node-forge // Simulate window for node-forge
var window = globalThis; 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 // Load pdf-lib
eval(UrlFetchApp.fetch("https://unpkg.com/pdf-lib@1.17.1/dist/pdf-lib.min.js").getContentText()); 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. // It is necessary for drawing text for signature.