From f14215da37ec596ab636cd9db1d8ff31e9bcb108 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 24 May 2020 13:53:29 +0200 Subject: [PATCH] Implement fill opacity for shading patterns in the SVG back-end In the PDF file from the issue below, the fill alpha (`ca`) is set before drawing the circles using the `setGState` operator. Doing so causes the global alpha to be set on the canvas' context for the canvas back-end, but this was not handled in the SVG back-end. This patch fixes that by taking the fill opacity into account when drawing shading patterns in the same way as done elsewhere so it is only included if the value is non-default. Fixes #11812. --- src/display/svg.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/display/svg.js b/src/display/svg.js index 4631b5d4f..3aa4cf083 100644 --- a/src/display/svg.js +++ b/src/display/svg.js @@ -1090,6 +1090,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { rect.setAttributeNS(null, "width", x1 - x0); rect.setAttributeNS(null, "height", y1 - y0); rect.setAttributeNS(null, "fill", this._makeShadingPattern(args)); + if (this.current.fillAlpha < 1) { + rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha); + } this._ensureTransformGroup().appendChild(rect); }