From 4dc5bf8e695e43a9156d1e39e6b6f5d13dd154fe Mon Sep 17 00:00:00 2001 From: "chris.greening" Date: Wed, 17 May 2017 15:25:29 +0100 Subject: [PATCH] Renames parameter to background Adds more documentation Changes to ES6 --- src/display/api.js | 9 ++++++--- src/display/canvas.js | 6 +++--- test/unit/custom_spec.js | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 3bbb21ba09f89b..7012038835fb96 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -717,8 +717,11 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * @property {Object} canvasFactory - (optional) The factory that will be used * when creating canvases. The default value is * {DOMCanvasFactory}. - * @property {string} backgroundColor - (optional) Background color to use for - * the canvas. The default value is 'rgb(255,255,255)'. + * @property {Object} background - (optional) Background to use for the canvas. + * Can use any valid canvas.fillStyle: A DOMString parsed as + * CSS value, a CanvasGradient object (a linear or + * radial gradient) or a CanvasPattern object (a repetitive + * image). The default value is 'rgb(255,255,255)'. */ /** @@ -2134,7 +2137,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { transform: params.transform, viewport: params.viewport, transparency, - backgroundColor: params.backgroundColor, + background: params.background, }); this.operatorListIdx = 0; this.graphicsReady = true; diff --git a/src/display/canvas.js b/src/display/canvas.js index 904d36688f6921..bc9861cfbcaa60 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -705,8 +705,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { CanvasGraphics.prototype = { - beginDrawing: function CanvasGraphics_beginDrawing({ - transform, viewport, transparency, backgroundColor = null, + beginDrawing({ + transform, viewport, transparency, background = null, }) { // For pdfs that use blend modes we have to clear the canvas else certain // blend modes can look wrong since we'd be blending with a white @@ -717,7 +717,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { var height = this.ctx.canvas.height; this.ctx.save(); - this.ctx.fillStyle = backgroundColor || 'rgb(255, 255, 255)'; + this.ctx.fillStyle = background || 'rgb(255, 255, 255)'; this.ctx.fillRect(0, 0, width, height); this.ctx.restore(); diff --git a/test/unit/custom_spec.js b/test/unit/custom_spec.js index 4a503002a0f12d..0a31c27e49d2c9 100644 --- a/test/unit/custom_spec.js +++ b/test/unit/custom_spec.js @@ -94,7 +94,7 @@ describe('custom canvas rendering', function() { page.render({ canvasContext: canvasAndCtx.context, viewport, - backgroundColor: 'rgba(255,0,0,1.0)' + background: 'rgba(255,0,0,1.0)' }).then(function() { var { r, g, b, a } = getTopLeftPixel(canvasAndCtx.context); CanvasFactory.destroy(canvasAndCtx);