From 0c321466dce4377f58a038515260c66a0f74603b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Thu, 27 Oct 2011 05:45:10 +0300 Subject: [PATCH] Set DeviceGray as initial value for color space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the PDF reference, section 4.3 Graphics State, table 4.2, third row. > The current color space in which color values are to be interpreted > (see Section 4.5, “Color Spaces”). There are two separate color space > parameters: one for stroking and one for all other painting opera- > tions. Initial value: DeviceGray. The problem before was that certain PDFs didn't explicitly set the color space, so a call to `setFillColor` or `setStrokeColor` were failing when the `getRgb` method was call, as the color space was null. See source code of CanvasGraphics.prototype.setFillColor/setStrokeColor. --- pdf.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pdf.js b/pdf.js index 43df4a168..cb3ca3dc5 100644 --- a/pdf.js +++ b/pdf.js @@ -5344,6 +5344,9 @@ var CanvasExtraState = (function canvasExtraState() { this.strokeColor = '#000000'; this.old = old; + + this.fillColorSpace = new DeviceGrayCS; + this.strokeColorSpace = new DeviceGrayCS; } constructor.prototype = {