From 487ba9065a4f3ee5f1b099d980436c709cfe875e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 20 Oct 2015 20:25:29 +0200 Subject: [PATCH] Fail gracefully, and with a notification, if paintXObject is encountered in canvas.js We should never actually try to execute `paintXObject` in canvas.js, but in some cases where we fail to parse the PDF file correctly it can happen. Currently this will potentially cause an entire page to fail to render, which seems suboptimal. With this patch, we will instead continue rendering with a warning that things might not work correctly. --- src/display/canvas.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index 4e55d0271..d66c318bd 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals error, PDFJS, assert, info, shadow, TextRenderingMode, - FONT_IDENTITY_MATRIX, Uint32ArrayView, IDENTITY_MATRIX, ImageData, - ImageKind, isArray, isNum, TilingPattern, OPS, Util, warn, - getShadingPatternFromIR, WebGLUtils */ +/* globals IDENTITY_MATRIX, FONT_IDENTITY_MATRIX, TextRenderingMode, ImageData, + ImageKind, PDFJS, Uint32ArrayView, error, WebGLUtils, OPS, warn, + shadow, isNum, Util, TilingPattern, getShadingPatternFromIR, isArray, + info, assert, UnsupportedManager, UNSUPPORTED_FEATURES */ 'use strict'; @@ -2073,6 +2073,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { this.ctx.fillRect(0, 0, 1, 1); }, + paintXObject: function CanvasGraphics_paintXObject() { + UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown); + warn('Unsupported \'paintXObject\' command.'); + }, + // Marked content markPoint: function CanvasGraphics_markPoint(tag) {