From c7dff95b56b16d47dd7fe75222a5c75c407ae37c Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Tue, 27 Sep 2016 19:25:53 +0100 Subject: [PATCH] PDF.js version 1.5.490 - See mozilla/pdf.js@7f381c8064f7f67668892130f5f7f818658098ca --- bower.json | 2 +- build/pdf.combined.js | 65 ++++++++++++++++++++++++++++++++----------- build/pdf.js | 4 +-- build/pdf.worker.js | 65 ++++++++++++++++++++++++++++++++----------- package.json | 2 +- 5 files changed, 100 insertions(+), 38 deletions(-) diff --git a/bower.json b/bower.json index 395b7d809..8c033a4de 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.5.488", + "version": "1.5.490", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index a62a14fe1..70941376c 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.5.488'; -var pdfjsBuild = '6c263c1'; +var pdfjsVersion = '1.5.490'; +var pdfjsBuild = '7f381c8'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -11184,7 +11184,7 @@ var error = sharedUtil.error; * (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf) */ -var JpegImage = (function jpegImage() { +var JpegImage = (function JpegImageClosure() { var dctZigZag = new Uint8Array([ 0, 1, 8, @@ -11212,7 +11212,9 @@ var JpegImage = (function jpegImage() { var dctSqrt2 = 5793; // sqrt(2) var dctSqrt1d2 = 2896; // sqrt(2) / 2 - function constructor() { + function JpegImage() { + this.decodeTransform = null; + this.colorTransform = -1; } function buildHuffmanTable(codeLengths, values) { @@ -11729,7 +11731,7 @@ var JpegImage = (function jpegImage() { return a <= 0 ? 0 : a >= 255 ? 255 : a; } - constructor.prototype = { + JpegImage.prototype = { parse: function parse(data) { function readUint16() { @@ -12046,8 +12048,20 @@ var JpegImage = (function jpegImage() { // The adobe transform marker overrides any previous setting return true; } else if (this.numComponents === 3) { + if (!this.adobe && this.colorTransform === 0) { + // If the Adobe transform marker is not present and the image + // dictionary has a 'ColorTransform' entry, explicitly set to `0`, + // then the colours should *not* be transformed. + return false; + } return true; - } else { + } else { // `this.numComponents !== 3` + if (!this.adobe && this.colorTransform === 1) { + // If the Adobe transform marker is not present and the image + // dictionary has a 'ColorTransform' entry, explicitly set to `1`, + // then the colours should be transformed. + return true; + } return false; } }, @@ -12189,7 +12203,7 @@ var JpegImage = (function jpegImage() { rgbData[offset++] = grayColor; } return rgbData; - } else if (this.numComponents === 3) { + } else if (this.numComponents === 3 && this._isColorConversionNeeded()) { return this._convertYccToRgb(data); } else if (this.numComponents === 4) { if (this._isColorConversionNeeded()) { @@ -12206,7 +12220,7 @@ var JpegImage = (function jpegImage() { } }; - return constructor; + return JpegImage; })(); exports.JpegImage = JpegImage; @@ -21685,6 +21699,7 @@ exports.SVGGraphics = SVGGraphics; var Util = sharedUtil.Util; var error = sharedUtil.error; var info = sharedUtil.info; +var isInt = sharedUtil.isInt; var isArray = sharedUtil.isArray; var createObjectURL = sharedUtil.createObjectURL; var shadow = sharedUtil.shadow; @@ -22542,7 +22557,7 @@ var PredictorStream = (function PredictorStreamClosure() { * DecodeStreams. */ var JpegStream = (function JpegStreamClosure() { - function JpegStream(stream, maybeLength, dict, xref) { + function JpegStream(stream, maybeLength, dict) { // Some images may contain 'junk' before the SOI (start-of-image) marker. // Note: this seems to mainly affect inline images. var ch; @@ -22576,8 +22591,8 @@ var JpegStream = (function JpegStreamClosure() { var jpegImage = new JpegImage(); // Checking if values need to be transformed before conversion. - if (this.forceRGB && this.dict && isArray(this.dict.get('Decode'))) { - var decodeArr = this.dict.getArray('Decode'); + var decodeArr = this.dict.getArray('Decode', 'D'); + if (this.forceRGB && isArray(decodeArr)) { var bitsPerComponent = this.dict.get('BitsPerComponent') || 8; var decodeArrLength = decodeArr.length; var transform = new Int32Array(decodeArrLength); @@ -22594,6 +22609,14 @@ var JpegStream = (function JpegStreamClosure() { jpegImage.decodeTransform = transform; } } + // Fetching the 'ColorTransform' entry, if it exists. + var decodeParams = this.dict.get('DecodeParms', 'DP'); + if (isDict(decodeParams)) { + var colorTransform = decodeParams.get('ColorTransform'); + if (isInt(colorTransform)) { + jpegImage.colorTransform = colorTransform; + } + } jpegImage.parse(this.bytes); var data = jpegImage.getData(this.drawWidth, this.drawHeight, @@ -22715,7 +22738,7 @@ var Jbig2Stream = (function Jbig2StreamClosure() { var jbig2Image = new Jbig2Image(); var chunks = []; - var decodeParams = this.dict.getArray('DecodeParms'); + var decodeParams = this.dict.getArray('DecodeParms', 'DP'); // According to the PDF specification, DecodeParms can be either // a dictionary, or an array whose elements are dictionaries. @@ -29532,7 +29555,7 @@ var Parser = (function ParserClosure() { } if (name === 'DCTDecode' || name === 'DCT') { xrefStreamStats[StreamType.DCT] = true; - return new JpegStream(stream, maybeLength, stream.dict, this.xref); + return new JpegStream(stream, maybeLength, stream.dict); } if (name === 'JPXDecode' || name === 'JPX') { xrefStreamStats[StreamType.JPX] = true; @@ -45939,18 +45962,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { */ NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) { - var cs = ColorSpace.parse(image.dict.get('ColorSpace', 'CS'), xref, res); + var dict = image.dict; + if (dict.has('DecodeParms') || dict.has('DP')) { + return false; + } + var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && - cs.isDefaultDecode(image.dict.getArray('Decode', 'D')); + cs.isDefaultDecode(dict.getArray('Decode', 'D')); }; /** * Checks if the image can be decoded by the browser. */ NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) { - var cs = ColorSpace.parse(image.dict.get('ColorSpace', 'CS'), xref, res); + var dict = image.dict; + if (dict.has('DecodeParms') || dict.has('DP')) { + return false; + } + var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); return (cs.numComps === 1 || cs.numComps === 3) && - cs.isDefaultDecode(image.dict.getArray('Decode', 'D')); + cs.isDefaultDecode(dict.getArray('Decode', 'D')); }; function PartialEvaluator(pdfManager, xref, handler, pageIndex, diff --git a/build/pdf.js b/build/pdf.js index 34dcaaccc..de78b034f 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.5.488'; -var pdfjsBuild = '6c263c1'; +var pdfjsVersion = '1.5.490'; +var pdfjsBuild = '7f381c8'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 5c780b4b0..8bd8daf37 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.5.488'; -var pdfjsBuild = '6c263c1'; +var pdfjsVersion = '1.5.490'; +var pdfjsBuild = '7f381c8'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -11184,7 +11184,7 @@ var error = sharedUtil.error; * (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf) */ -var JpegImage = (function jpegImage() { +var JpegImage = (function JpegImageClosure() { var dctZigZag = new Uint8Array([ 0, 1, 8, @@ -11212,7 +11212,9 @@ var JpegImage = (function jpegImage() { var dctSqrt2 = 5793; // sqrt(2) var dctSqrt1d2 = 2896; // sqrt(2) / 2 - function constructor() { + function JpegImage() { + this.decodeTransform = null; + this.colorTransform = -1; } function buildHuffmanTable(codeLengths, values) { @@ -11729,7 +11731,7 @@ var JpegImage = (function jpegImage() { return a <= 0 ? 0 : a >= 255 ? 255 : a; } - constructor.prototype = { + JpegImage.prototype = { parse: function parse(data) { function readUint16() { @@ -12046,8 +12048,20 @@ var JpegImage = (function jpegImage() { // The adobe transform marker overrides any previous setting return true; } else if (this.numComponents === 3) { + if (!this.adobe && this.colorTransform === 0) { + // If the Adobe transform marker is not present and the image + // dictionary has a 'ColorTransform' entry, explicitly set to `0`, + // then the colours should *not* be transformed. + return false; + } return true; - } else { + } else { // `this.numComponents !== 3` + if (!this.adobe && this.colorTransform === 1) { + // If the Adobe transform marker is not present and the image + // dictionary has a 'ColorTransform' entry, explicitly set to `1`, + // then the colours should be transformed. + return true; + } return false; } }, @@ -12189,7 +12203,7 @@ var JpegImage = (function jpegImage() { rgbData[offset++] = grayColor; } return rgbData; - } else if (this.numComponents === 3) { + } else if (this.numComponents === 3 && this._isColorConversionNeeded()) { return this._convertYccToRgb(data); } else if (this.numComponents === 4) { if (this._isColorConversionNeeded()) { @@ -12206,7 +12220,7 @@ var JpegImage = (function jpegImage() { } }; - return constructor; + return JpegImage; })(); exports.JpegImage = JpegImage; @@ -19805,6 +19819,7 @@ exports.isStream = isStream; var Util = sharedUtil.Util; var error = sharedUtil.error; var info = sharedUtil.info; +var isInt = sharedUtil.isInt; var isArray = sharedUtil.isArray; var createObjectURL = sharedUtil.createObjectURL; var shadow = sharedUtil.shadow; @@ -20662,7 +20677,7 @@ var PredictorStream = (function PredictorStreamClosure() { * DecodeStreams. */ var JpegStream = (function JpegStreamClosure() { - function JpegStream(stream, maybeLength, dict, xref) { + function JpegStream(stream, maybeLength, dict) { // Some images may contain 'junk' before the SOI (start-of-image) marker. // Note: this seems to mainly affect inline images. var ch; @@ -20696,8 +20711,8 @@ var JpegStream = (function JpegStreamClosure() { var jpegImage = new JpegImage(); // Checking if values need to be transformed before conversion. - if (this.forceRGB && this.dict && isArray(this.dict.get('Decode'))) { - var decodeArr = this.dict.getArray('Decode'); + var decodeArr = this.dict.getArray('Decode', 'D'); + if (this.forceRGB && isArray(decodeArr)) { var bitsPerComponent = this.dict.get('BitsPerComponent') || 8; var decodeArrLength = decodeArr.length; var transform = new Int32Array(decodeArrLength); @@ -20714,6 +20729,14 @@ var JpegStream = (function JpegStreamClosure() { jpegImage.decodeTransform = transform; } } + // Fetching the 'ColorTransform' entry, if it exists. + var decodeParams = this.dict.get('DecodeParms', 'DP'); + if (isDict(decodeParams)) { + var colorTransform = decodeParams.get('ColorTransform'); + if (isInt(colorTransform)) { + jpegImage.colorTransform = colorTransform; + } + } jpegImage.parse(this.bytes); var data = jpegImage.getData(this.drawWidth, this.drawHeight, @@ -20835,7 +20858,7 @@ var Jbig2Stream = (function Jbig2StreamClosure() { var jbig2Image = new Jbig2Image(); var chunks = []; - var decodeParams = this.dict.getArray('DecodeParms'); + var decodeParams = this.dict.getArray('DecodeParms', 'DP'); // According to the PDF specification, DecodeParms can be either // a dictionary, or an array whose elements are dictionaries. @@ -25639,7 +25662,7 @@ var Parser = (function ParserClosure() { } if (name === 'DCTDecode' || name === 'DCT') { xrefStreamStats[StreamType.DCT] = true; - return new JpegStream(stream, maybeLength, stream.dict, this.xref); + return new JpegStream(stream, maybeLength, stream.dict); } if (name === 'JPXDecode' || name === 'JPX') { xrefStreamStats[StreamType.JPX] = true; @@ -37057,18 +37080,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { */ NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) { - var cs = ColorSpace.parse(image.dict.get('ColorSpace', 'CS'), xref, res); + var dict = image.dict; + if (dict.has('DecodeParms') || dict.has('DP')) { + return false; + } + var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && - cs.isDefaultDecode(image.dict.getArray('Decode', 'D')); + cs.isDefaultDecode(dict.getArray('Decode', 'D')); }; /** * Checks if the image can be decoded by the browser. */ NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) { - var cs = ColorSpace.parse(image.dict.get('ColorSpace', 'CS'), xref, res); + var dict = image.dict; + if (dict.has('DecodeParms') || dict.has('DP')) { + return false; + } + var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); return (cs.numComps === 1 || cs.numComps === 3) && - cs.isDefaultDecode(image.dict.getArray('Decode', 'D')); + cs.isDefaultDecode(dict.getArray('Decode', 'D')); }; function PartialEvaluator(pdfManager, xref, handler, pageIndex, diff --git a/package.json b/package.json index 5539341cc..3e289f199 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.5.488", + "version": "1.5.490", "main": "build/pdf.js", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [