mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Allow loading pdf fonts into another document.
This commit is contained in:
parent
fea40442f7
commit
ac723a1760
5 changed files with 166 additions and 19 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue