From a570f5df745ef234564ade0598b79fee6183ba09 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 21 Dec 2017 23:38:01 +0800 Subject: [PATCH] Update useCORS documentation (Fix #1323) --- docs/configuration.md | 1 + src/Clone.js | 1 + src/index.js | 2 ++ 3 files changed, 4 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 7d95362..6f4e10a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -21,6 +21,7 @@ These are all of the available configuration options. | proxy | `null` | Url to the [proxy](/proxy/) which is to be used for loading cross-origin images. If left empty, cross-origin images won't be loaded. | removeContainer | `true` | Whether to cleanup the cloned DOM elements html2canvas creates temporarily | scale | `window.devicePixelRatio` | The scale to use for rendering. Defaults to the browsers device pixel ratio. +| useCORS | `false` | Whether to attempt to load images from a server using CORS | width | `Element` width | The width of the `canvas` | height | `Element` height | The height of the `canvas` | x | `Element` x-offset | Crop canvas x-coordinate diff --git a/src/Clone.js b/src/Clone.js index c60ca9d..646636c 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -182,6 +182,7 @@ export class DocumentCloner { removeContainer: this.options.removeContainer, scale: this.options.scale, foreignObjectRendering: this.options.foreignObjectRendering, + useCORS: this.options.useCORS, target: new CanvasRenderer(), width, height, diff --git a/src/index.js b/src/index.js index 19058f1..45431c6 100644 --- a/src/index.js +++ b/src/index.js @@ -20,6 +20,7 @@ export type Options = { removeContainer: ?boolean, scale: number, target: RenderTarget<*>, + useCORS: boolean, width: number, height: number, x: number, @@ -72,6 +73,7 @@ const html2canvas = (element: HTMLElement, conf: ?Options): Promise<*> => { foreignObjectRendering: false, scale: defaultView.devicePixelRatio || 1, target: new CanvasRenderer(config.canvas), + useCORS: false, x: left, y: top, width: Math.ceil(width),