Allow loading pdf fonts into another document.

This commit is contained in:
Jonathan Grimes 2020-07-27 17:22:45 +00:00
parent fea40442f7
commit ac723a1760
5 changed files with 166 additions and 19 deletions

View file

@ -65,11 +65,16 @@ class BaseCanvasFactory {
}
class DOMCanvasFactory extends BaseCanvasFactory {
constructor({ ownerDocument = globalThis.document } = {}) {
super();
this._document = ownerDocument;
}
create(width, height) {
if (width <= 0 || height <= 0) {
throw new Error("Invalid canvas size");
}
const canvas = document.createElement("canvas");
const canvas = this._document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.width = width;
canvas.height = height;