I used AI to quickly prototype this function to replace the existing one in text_insertion.js:
async function createPngImageFromText(textSettings) {
// Grab the image element
const imgElement = document.getElementById("myImage");
if (!imgElement) {
throw new Error("Image element #myImage not found");
}
// Create an ArrayPngImage from the image's Base64 data
const base64Data = imgElement.src.split(",")[1]; // strip "data:image/png;base64,"
const binaryStr = atob(base64Data);
const len = binaryStr.length;
const buffer = new Uint8Array(len);
for (let i = 0; i < len; i++) {
buffer[i] = binaryStr.charCodeAt(i);
}
// Create the ArrayPngImage using HOOPS Web Viewer API
const image = new ArrayPngImage(buffer, imgElement.width, imgElement.height);
return image;
}
You will need to include your image tag called “myImage” in text_insertion.html, something like:
<img id="myImage" src="data:image/png;base64,iVBORw0KGgoA....and..so..on" style="display:none;">
