From 4deb3bd04bb458874f3191c4bcd54f4d1c53a7fc Mon Sep 17 00:00:00 2001 From: Jani Pehkonen Date: Tue, 5 Sep 2017 21:44:53 +0300 Subject: [PATCH] Fix color of image masks inside uncolored patterns --- src/display/pattern_helper.js | 10 ++++++++-- test/pdfs/issue3226.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/pdfs/issue3226.pdf.link diff --git a/src/display/pattern_helper.js b/src/display/pattern_helper.js index ac2cef6405eded..eb129b4fe44787 100644 --- a/src/display/pattern_helper.js +++ b/src/display/pattern_helper.js @@ -360,7 +360,7 @@ var TilingPattern = (function TilingPatternClosure() { var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); graphics.groupLevel = owner.groupLevel; - this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color); + this.setFillAndStrokeStyleToContext(graphics, paintType, color); this.setScale(width, height, xstep, ystep); this.transformToScale(graphics); @@ -401,17 +401,23 @@ var TilingPattern = (function TilingPatternClosure() { }, setFillAndStrokeStyleToContext: - function setFillAndStrokeStyleToContext(context, paintType, color) { + function setFillAndStrokeStyleToContext(graphics, paintType, color) { + let context = graphics.ctx, current = graphics.current; switch (paintType) { case PaintType.COLORED: var ctx = this.ctx; context.fillStyle = ctx.fillStyle; context.strokeStyle = ctx.strokeStyle; + current.fillColor = ctx.fillStyle; + current.strokeColor = ctx.strokeStyle; break; case PaintType.UNCOLORED: var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); context.fillStyle = cssColor; context.strokeStyle = cssColor; + // Set color needed by image masks (fixes issues 3226 and 8741). + current.fillColor = cssColor; + current.strokeColor = cssColor; break; default: throw new FormatError(`Unsupported paint type: ${paintType}`); diff --git a/test/pdfs/issue3226.pdf.link b/test/pdfs/issue3226.pdf.link new file mode 100644 index 00000000000000..6ee6b0b0b5cd0d --- /dev/null +++ b/test/pdfs/issue3226.pdf.link @@ -0,0 +1 @@ +https://web.archive.org/web/20170830175223/http://arxiv.org/pdf/0705.4298.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index de8aa12000f604..adeececbff2b9f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -698,6 +698,14 @@ "lastPage": 1, "type": "load" }, + { "id": "issue3226", + "file": "pdfs/issue3226.pdf", + "md5": "195658acd0e6bd6c34e0ef4e3f272a49", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "eq" + }, { "id": "issue5599", "file": "pdfs/issue5599.pdf", "md5": "529a4a9409ac024aeb57a047210280fe",