Browse Source

PDF.js version 1.8.548 - See mozilla/pdf.js@ca3c08f12b1b1e70523d06b54232d26e07244f43

master v1.8.548
pdfjsbot 8 years ago
parent
commit
4440e6805a
  1. 2
      bower.json
  2. 96
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 96
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 12
      build/pdf.min.js
  7. 4
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 4
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 84
      lib/display/svg.js
  12. 164
      lib/examples/node/domstubs.js
  13. 4
      lib/pdf.js
  14. 4
      lib/pdf.worker.js
  15. 118
      lib/test/unit/display_svg_spec.js
  16. 2
      lib/test/unit/jasmine-boot.js
  17. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.542", "version": "1.8.548",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

96
build/pdf.combined.js

@ -13116,8 +13116,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.542'; exports.version = version = '1.8.548';
exports.build = build = '26be1df5'; exports.build = build = 'ca3c08f1';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -13206,6 +13206,58 @@ var SVGGraphics = function SVGGraphics() {
} }
return b << 16 | a; return b << 16 | a;
} }
function deflateSync(literals) {
if (!(0, _util.isNodeJS)()) {
return deflateSyncUncompressed(literals);
}
try {
var input;
if (parseInt(process.versions.node) >= 8) {
input = literals;
} else {
input = new Buffer(literals);
}
var output = require('zlib').deflateSync(input, { level: 9 });
return output instanceof Uint8Array ? output : new Uint8Array(output);
} catch (e) {
(0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
}
return deflateSyncUncompressed(literals);
}
function deflateSyncUncompressed(literals) {
var len = literals.length;
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
return idat;
}
function encode(imgData, kind, forceDataSchema) { function encode(imgData, kind, forceDataSchema) {
var width = imgData.width; var width = imgData.width;
var height = imgData.height; var height = imgData.height;
@ -13250,37 +13302,7 @@ var SVGGraphics = function SVGGraphics() {
} }
} }
var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]); var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
var len = literals.length; var idat = deflateSync(literals);
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
var data = new Uint8Array(pngLength); var data = new Uint8Array(pngLength);
var offset = 0; var offset = 0;
@ -28605,8 +28627,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.542'; PDFJS.version = '1.8.548';
PDFJS.build = '26be1df5'; PDFJS.build = 'ca3c08f1';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -47232,8 +47254,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.542'; var pdfjsVersion = '1.8.548';
var pdfjsBuild = '26be1df5'; var pdfjsBuild = 'ca3c08f1';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(25); var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
var pdfjsDisplayAPI = __w_pdfjs_require__(10); var pdfjsDisplayAPI = __w_pdfjs_require__(10);

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

96
build/pdf.js

@ -3849,8 +3849,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.542'; exports.version = version = '1.8.548';
exports.build = build = '26be1df5'; exports.build = build = 'ca3c08f1';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -3939,6 +3939,58 @@ var SVGGraphics = function SVGGraphics() {
} }
return b << 16 | a; return b << 16 | a;
} }
function deflateSync(literals) {
if (!(0, _util.isNodeJS)()) {
return deflateSyncUncompressed(literals);
}
try {
var input;
if (parseInt(process.versions.node) >= 8) {
input = literals;
} else {
input = new Buffer(literals);
}
var output = require('zlib').deflateSync(input, { level: 9 });
return output instanceof Uint8Array ? output : new Uint8Array(output);
} catch (e) {
(0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
}
return deflateSyncUncompressed(literals);
}
function deflateSyncUncompressed(literals) {
var len = literals.length;
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
return idat;
}
function encode(imgData, kind, forceDataSchema) { function encode(imgData, kind, forceDataSchema) {
var width = imgData.width; var width = imgData.width;
var height = imgData.height; var height = imgData.height;
@ -3983,37 +4035,7 @@ var SVGGraphics = function SVGGraphics() {
} }
} }
var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]); var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
var len = literals.length; var idat = deflateSync(literals);
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
var data = new Uint8Array(pngLength); var data = new Uint8Array(pngLength);
var offset = 0; var offset = 0;
@ -5883,8 +5905,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.542'; PDFJS.version = '1.8.548';
PDFJS.build = '26be1df5'; PDFJS.build = 'ca3c08f1';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -11422,8 +11444,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.542'; var pdfjsVersion = '1.8.548';
var pdfjsBuild = '26be1df5'; var pdfjsBuild = 'ca3c08f1';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(8); var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
var pdfjsDisplayAPI = __w_pdfjs_require__(3); var pdfjsDisplayAPI = __w_pdfjs_require__(3);

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

12
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -40390,8 +40390,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.8.542'; var pdfjsVersion = '1.8.548';
var pdfjsBuild = '26be1df5'; var pdfjsBuild = 'ca3c08f1';
var pdfjsCoreWorker = __w_pdfjs_require__(8); var pdfjsCoreWorker = __w_pdfjs_require__(8);
{ {
__w_pdfjs_require__(18); __w_pdfjs_require__(18);

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1480,8 +1480,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.542'; exports.version = version = '1.8.548';
exports.build = build = '26be1df5'; exports.build = build = 'ca3c08f1';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.542'; PDFJS.version = '1.8.548';
PDFJS.build = '26be1df5'; PDFJS.build = 'ca3c08f1';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {

84
lib/display/svg.js

@ -84,6 +84,58 @@ var SVGGraphics = function SVGGraphics() {
} }
return b << 16 | a; return b << 16 | a;
} }
function deflateSync(literals) {
if (!(0, _util.isNodeJS)()) {
return deflateSyncUncompressed(literals);
}
try {
var input;
if (parseInt(process.versions.node) >= 8) {
input = literals;
} else {
input = new Buffer(literals);
}
var output = require('zlib').deflateSync(input, { level: 9 });
return output instanceof Uint8Array ? output : new Uint8Array(output);
} catch (e) {
(0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
}
return deflateSyncUncompressed(literals);
}
function deflateSyncUncompressed(literals) {
var len = literals.length;
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
return idat;
}
function encode(imgData, kind, forceDataSchema) { function encode(imgData, kind, forceDataSchema) {
var width = imgData.width; var width = imgData.width;
var height = imgData.height; var height = imgData.height;
@ -128,37 +180,7 @@ var SVGGraphics = function SVGGraphics() {
} }
} }
var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]); var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
var len = literals.length; var idat = deflateSync(literals);
var maxBlockLength = 0xFFFF;
var deflateBlocks = Math.ceil(len / maxBlockLength);
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
var pi = 0;
idat[pi++] = 0x78;
idat[pi++] = 0x9c;
var pos = 0;
while (len > maxBlockLength) {
idat[pi++] = 0x00;
idat[pi++] = 0xff;
idat[pi++] = 0xff;
idat[pi++] = 0x00;
idat[pi++] = 0x00;
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
pi += maxBlockLength;
pos += maxBlockLength;
len -= maxBlockLength;
}
idat[pi++] = 0x01;
idat[pi++] = len & 0xff;
idat[pi++] = len >> 8 & 0xff;
idat[pi++] = ~len & 0xffff & 0xff;
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
idat.set(literals.subarray(pos), pi);
pi += literals.length - pos;
var adler = adler32(literals, 0, literals.length);
idat[pi++] = adler >> 24 & 0xff;
idat[pi++] = adler >> 16 & 0xff;
idat[pi++] = adler >> 8 & 0xff;
idat[pi++] = adler & 0xff;
var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
var data = new Uint8Array(pngLength); var data = new Uint8Array(pngLength);
var offset = 0; var offset = 0;

164
lib/examples/node/domstubs.js

@ -0,0 +1,164 @@
/* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
function xmlEncode(s) {
var i = 0,
ch;
s = String(s);
while (i < s.length && (ch = s[i]) !== '&' && ch !== '<' && ch !== '\"' && ch !== '\n' && ch !== '\r' && ch !== '\t') {
i++;
}
if (i >= s.length) {
return s;
}
var buf = s.substring(0, i);
while (i < s.length) {
ch = s[i++];
switch (ch) {
case '&':
buf += '&amp;';
break;
case '<':
buf += '&lt;';
break;
case '\"':
buf += '&quot;';
break;
case '\n':
buf += '&#xA;';
break;
case '\r':
buf += '&#xD;';
break;
case '\t':
buf += '&#x9;';
break;
default:
buf += ch;
break;
}
}
return buf;
}
function DOMElement(name) {
this.nodeName = name;
this.childNodes = [];
this.attributes = {};
this.textContent = '';
if (name === 'style') {
this.sheet = {
cssRules: [],
insertRule: function insertRule(rule) {
this.cssRules.push(rule);
}
};
}
}
DOMElement.prototype = {
getAttributeNS: function DOMElement_getAttributeNS(NS, name) {
return name in this.attributes ? this.attributes[name] : null;
},
setAttributeNS: function DOMElement_setAttributeNS(NS, name, value) {
value = value || '';
value = xmlEncode(value);
this.attributes[name] = value;
},
appendChild: function DOMElement_appendChild(element) {
var childNodes = this.childNodes;
if (childNodes.indexOf(element) === -1) {
childNodes.push(element);
}
},
toString: function DOMElement_toString() {
var buf = [];
buf.push('<' + this.nodeName);
if (this.nodeName === 'svg:svg') {
buf.push(' xmlns:xlink="http://www.w3.org/1999/xlink"' + ' xmlns:svg="http://www.w3.org/2000/svg"');
}
for (var i in this.attributes) {
buf.push(' ' + i + '="' + xmlEncode(this.attributes[i]) + '"');
}
buf.push('>');
if (this.nodeName === 'svg:tspan' || this.nodeName === 'svg:style') {
buf.push(xmlEncode(this.textContent));
} else {
this.childNodes.forEach(function (childNode) {
buf.push(childNode.toString());
});
}
buf.push('</' + this.nodeName + '>');
return buf.join('');
},
cloneNode: function DOMElement_cloneNode() {
var newNode = new DOMElement(this.nodeName);
newNode.childNodes = this.childNodes;
newNode.attributes = this.attributes;
newNode.textContent = this.textContent;
return newNode;
}
};
var document = {
childNodes: [],
get currentScript() {
return { src: '' };
},
get documentElement() {
return this;
},
createElementNS: function createElementNS(NS, element) {
var elObject = new DOMElement(element);
return elObject;
},
createElement: function createElement(element) {
return this.createElementNS('', element);
},
getElementsByTagName: function getElementsByTagName(element) {
if (element === 'head') {
return [this.head || (this.head = new DOMElement('head'))];
}
return [];
}
};
function Image() {
this._src = null;
this.onload = null;
}
Image.prototype = {
get src() {
return this._src;
},
set src(value) {
this._src = value;
if (this.onload) {
this.onload();
}
}
};
exports.document = document;
exports.Image = Image;
var exported_symbols = Object.keys(exports);
exports.setStubs = function (namespace) {
exported_symbols.forEach(function (key) {
console.assert(!(key in namespace), 'property should not be set: ' + key);
namespace[key] = exports[key];
});
};
exports.unsetStubs = function (namespace) {
exported_symbols.forEach(function (key) {
console.assert(key in namespace, 'property should be set: ' + key);
delete namespace[key];
});
};

4
lib/pdf.js

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.542'; var pdfjsVersion = '1.8.548';
var pdfjsBuild = '26be1df5'; var pdfjsBuild = 'ca3c08f1';
var pdfjsSharedUtil = require('./shared/util.js'); var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js'); var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js'); var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.542'; var pdfjsVersion = '1.8.548';
var pdfjsBuild = '26be1df5'; var pdfjsBuild = 'ca3c08f1';
var pdfjsCoreWorker = require('./core/worker.js'); var pdfjsCoreWorker = require('./core/worker.js');
{ {
require('./core/network.js'); require('./core/network.js');

118
lib/test/unit/display_svg_spec.js

@ -0,0 +1,118 @@
/* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var _util = require('../../shared/util');
var _domstubs = require('../../examples/node/domstubs');
var _test_utils = require('./test_utils');
var _api = require('../../display/api');
var _svg = require('../../display/svg');
function withZlib(isZlibRequired, callback) {
if (isZlibRequired) {
if (!(0, _util.isNodeJS)()) {
throw new Error('zlib test can only be run in Node.js');
}
return callback();
}
if (!(0, _util.isNodeJS)()) {
return callback();
}
var zlib = require('zlib');
var deflateSync = zlib.deflateSync;
zlib.deflateSync = function () {
throw new Error('zlib.deflateSync is explicitly disabled for testing.');
};
try {
return callback();
} finally {
zlib.deflateSync = deflateSync;
}
}
describe('SVGGraphics', function () {
var loadingTask;
var page;
beforeAll(function (done) {
loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('xobject-image.pdf', { nativeImageDecoderSupport: _util.NativeImageDecoding.DISPLAY }));
loadingTask.promise.then(function (doc) {
doc.getPage(1).then(function (firstPage) {
page = firstPage;
done();
});
});
});
afterAll(function (done) {
loadingTask.destroy().then(done);
});
describe('paintImageXObject', function () {
function getSVGImage() {
var svgGfx;
return page.getOperatorList().then(function (opList) {
var forceDataSchema = true;
svgGfx = new _svg.SVGGraphics(page.commonObjs, page.objs, forceDataSchema);
return svgGfx.loadDependencies(opList);
}).then(function () {
var svgImg;
var elementContainer = {
appendChild: function appendChild(element) {
svgImg = element;
}
};
var xobjectObjId = {
ref: 4,
gen: 0
};
if ((0, _util.isNodeJS)()) {
(0, _domstubs.setStubs)(global);
}
try {
svgGfx.paintImageXObject(xobjectObjId, elementContainer);
} finally {
if ((0, _util.isNodeJS)()) {
(0, _domstubs.unsetStubs)(global);
}
}
return svgImg;
});
}
it('should produce a reasonably small svg:image', function () {
if (!(0, _util.isNodeJS)()) {
pending('zlib.deflateSync is not supported in non-Node environments.');
}
withZlib(true, getSVGImage).then(function (svgImg) {
expect(svgImg.nodeName).toBe('svg:image');
expect(svgImg.getAttribute('width')).toBe('200px');
expect(svgImg.getAttribute('height')).toBe('100px');
var imgUrl = svgImg.getAttribute('xlink:href');
expect(imgUrl).toMatch(/^data:image\/png;base64,/);
expect(imgUrl.length).toBeLessThan(367);
});
});
it('should produce a svg:image even if zlib is unavailable', function () {
withZlib(false, getSVGImage).then(function (svgImg) {
expect(svgImg.nodeName).toBe('svg:image');
expect(svgImg.getAttribute('width')).toBe('200px');
expect(svgImg.getAttribute('height')).toBe('100px');
var imgUrl = svgImg.getAttribute('xlink:href');
expect(imgUrl).toMatch(/^data:image\/png;base64,/);
expect(imgUrl.length).toBe(80247);
});
});
});
});

2
lib/test/unit/jasmine-boot.js

@ -15,7 +15,7 @@
'use strict'; 'use strict';
function initializePDFJS(callback) { function initializePDFJS(callback) {
Promise.all(['pdfjs/display/global', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) { Promise.all(['pdfjs/display/global', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
return SystemJS.import(moduleName); return SystemJS.import(moduleName);
})).then(function (modules) { })).then(function (modules) {
var displayGlobal = modules[0]; var displayGlobal = modules[0];

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.542", "version": "1.8.548",
"main": "build/pdf.js", "main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [

Loading…
Cancel
Save