See https://bugzilla.mozilla.org/show_bug.cgi?id=1735738 for reference.
foreignObject.appendChild(style);
      var div = document.createElement("div");
      div.className = "textLayer";
      foreignObject.appendChild(div);
      stylePromise
        .then(async ([cssRules]) => {
          style.textContent = cssRules;
          
          var task = renderTextLayer({
            textContent,
            container: div,
            viewport,
            enhanceTextSelection,
          });
          await task.promise;
          task.expandTextDivs(true);
          svg.appendChild(foreignObject);
          writeSVG(svg, ctx, resolve, reject);
        })
        .catch(reason => {
          reject(new Error(`rasterizeTextLayer: "${reason?.message}".`));
        });
    });
  }
  return rasterizeTextLayer;
})();
/**
 * @class
 */
var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {