1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Adds additional parameter so background color of canvas can be set

This commit is contained in:
chris.greening 2017-05-16 12:01:03 +01:00
parent 08f8b68f12
commit cfc2f36f5c
8 changed files with 429 additions and 27 deletions

View file

@ -717,6 +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 {Object} background - (optional) Background to use for the canvas.
* Can use any valid canvas.fillStyle: A DOMString parsed as
* CSS <color> value, a CanvasGradient object (a linear or
* radial gradient) or a CanvasPattern object (a repetitive
* image). The default value is 'rgb(255,255,255)'.
*/
/**
@ -2128,7 +2133,12 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
this.objs, this.canvasFactory,
params.imageLayer);
this.gfx.beginDrawing(params.transform, params.viewport, transparency);
this.gfx.beginDrawing({
transform: params.transform,
viewport: params.viewport,
transparency,
background: params.background,
});
this.operatorListIdx = 0;
this.graphicsReady = true;
if (this.graphicsReadyCallback) {

View file

@ -705,8 +705,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
CanvasGraphics.prototype = {
beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport,
transparency) {
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
// backdrop. The problem with a transparent backdrop though is we then
@ -716,7 +716,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var height = this.ctx.canvas.height;
this.ctx.save();
this.ctx.fillStyle = 'rgb(255, 255, 255)';
this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();