Browse Source

PDF.js version 1.4.143 - See mozilla/pdf.js@21ed8ff71d581c56ee8c1f225199b8a5d901e7cb

master v1.4.143
Pdf Bot 9 years ago
parent
commit
0e8adafc2a
  1. 2
      bower.json
  2. 435
      build/pdf.combined.js
  3. 4
      build/pdf.js
  4. 435
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

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

435
build/pdf.combined.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.4.141';
var pdfjsBuild = '7ad8f3a';
var pdfjsVersion = '1.4.143';
var pdfjsBuild = '21ed8ff';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -30942,31 +30942,22 @@ var IdentityCMap = (function IdentityCMapClosure() { @@ -30942,31 +30942,22 @@ var IdentityCMap = (function IdentityCMapClosure() {
var BinaryCMapReader = (function BinaryCMapReaderClosure() {
function fetchBinaryData(url) {
var nonBinaryRequest = PDFJS.disableWorker;
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.open('GET', url, false);
if (!nonBinaryRequest) {
try {
request.open('GET', url, true);
request.responseType = 'arraybuffer';
nonBinaryRequest = request.responseType !== 'arraybuffer';
} catch (e) {
nonBinaryRequest = true;
}
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE) {
if (!request.response || request.status !== 200 &&
request.status !== 0) {
reject(new Error('Unable to get binary cMap at: ' + url));
} else {
resolve(new Uint8Array(request.response));
}
if (nonBinaryRequest && request.overrideMimeType) {
request.overrideMimeType('text/plain; charset=x-user-defined');
}
};
request.send(null);
if (nonBinaryRequest ? !request.responseText : !request.response) {
error('Unable to get binary cMap at: ' + url);
}
if (nonBinaryRequest) {
var data = Array.prototype.map.call(request.responseText, function (ch) {
return ch.charCodeAt(0) & 255;
});
return new Uint8Array(data);
}
return new Uint8Array(request.response);
}
function hexToInt(a, size) {
@ -31089,9 +31080,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -31089,9 +31080,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
};
function processBinaryCMap(url, cMap, extend) {
var data = fetchBinaryData(url);
return fetchBinaryData(url).then(function (data) {
var stream = new BinaryCMapStream(data);
var header = stream.readByte();
cMap.vertical = !!(header & 1);
@ -31190,8 +31180,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -31190,8 +31180,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
stream.readHexNumber(end, dataSize);
addHex(end, start, dataSize);
code = stream.readNumber();
cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize),
code);
cMap.mapCidRange(hexToInt(start, dataSize),
hexToInt(end, dataSize), code);
}
break;
case 4: // bfchar
@ -31243,9 +31233,10 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -31243,9 +31233,10 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
}
if (useCMap) {
extend(useCMap);
return extend(useCMap);
}
return cMap;
});
}
function BinaryCMapReader() {}
@ -31454,12 +31445,16 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -31454,12 +31445,16 @@ var CMapFactory = (function CMapFactoryClosure() {
useCMap = embededUseCMap;
}
if (useCMap) {
extendCMap(cMap, builtInCMapParams, useCMap);
return extendCMap(cMap, builtInCMapParams, useCMap);
} else {
return Promise.resolve(cMap);
}
}
function extendCMap(cMap, builtInCMapParams, useCMap) {
cMap.useCMap = createBuiltInCMap(useCMap, builtInCMapParams);
return createBuiltInCMap(useCMap, builtInCMapParams).then(
function(newCMap) {
cMap.useCMap = newCMap;
// If there aren't any code space ranges defined clone all the parent ones
// into this cMap.
if (cMap.numCodespaceRanges === 0) {
@ -31476,25 +31471,27 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -31476,25 +31471,27 @@ var CMapFactory = (function CMapFactoryClosure() {
cMap.mapOne(key, cMap.useCMap.lookup(key));
}
});
return cMap;
});
}
function parseBinaryCMap(name, builtInCMapParams) {
var url = builtInCMapParams.url + name + '.bcmap';
var cMap = new CMap(true);
new BinaryCMapReader().read(url, cMap, function (useCMap) {
extendCMap(cMap, builtInCMapParams, useCMap);
return new BinaryCMapReader().read(url, cMap, function (useCMap) {
return extendCMap(cMap, builtInCMapParams, useCMap);
});
return cMap;
}
function createBuiltInCMap(name, builtInCMapParams) {
if (name === 'Identity-H') {
return new IdentityCMap(false, 2);
return Promise.resolve(new IdentityCMap(false, 2));
} else if (name === 'Identity-V') {
return new IdentityCMap(true, 2);
return Promise.resolve(new IdentityCMap(true, 2));
}
if (BUILT_IN_CMAPS.indexOf(name) === -1) {
error('Unknown cMap name: ' + name);
return Promise.reject(new Error('Unknown cMap name: ' + name));
}
assert(builtInCMapParams, 'built-in cMap parameters are not provided');
@ -31502,17 +31499,28 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -31502,17 +31499,28 @@ var CMapFactory = (function CMapFactoryClosure() {
return parseBinaryCMap(name, builtInCMapParams);
}
var request = new XMLHttpRequest();
return new Promise(function (resolve, reject) {
var url = builtInCMapParams.url + name;
request.open('GET', url, false);
request.send(null);
if (!request.responseText) {
error('Unable to get cMap at: ' + url);
}
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE) {
if (request.status === 200 || request.status === 0) {
var cMap = new CMap(true);
var lexer = new Lexer(new StringStream(request.responseText));
parseCMap(cMap, lexer, builtInCMapParams, null);
return cMap;
parseCMap(cMap, lexer, builtInCMapParams, null).then(
function (parsedCMap) {
resolve(parsedCMap);
}).catch(function (e) {
reject(new Error({ message: 'Invalid CMap data', error: e }));
});
} else {
reject(new Error('Unable to get cMap at: ' + url));
}
}
};
request.open('GET', url, true);
request.send(null);
});
}
return {
@ -31522,17 +31530,15 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -31522,17 +31530,15 @@ var CMapFactory = (function CMapFactoryClosure() {
} else if (isStream(encoding)) {
var cMap = new CMap();
var lexer = new Lexer(encoding);
try {
parseCMap(cMap, lexer, builtInCMapParams, useCMap);
} catch (e) {
warn('Invalid CMap data. ' + e);
}
if (cMap.isIdentityCMap) {
return createBuiltInCMap(cMap.name, builtInCMapParams);
return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(
function (parsedCMap) {
if (parsedCMap.isIdentityCMap) {
return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
}
return cMap;
return parsedCMap;
});
}
error('Encoding required.');
return Promise.reject(new Error('Encoding required.'));
}
};
})();
@ -34278,7 +34284,7 @@ var Font = (function FontClosure() { @@ -34278,7 +34284,7 @@ var Font = (function FontClosure() {
this.fontMatrix = properties.fontMatrix;
this.bbox = properties.bbox;
this.toUnicode = properties.toUnicode = this.buildToUnicode(properties);
this.toUnicode = properties.toUnicode;
this.toFontChar = [];
@ -36442,138 +36448,6 @@ var Font = (function FontClosure() { @@ -36442,138 +36448,6 @@ var Font = (function FontClosure() {
return builder.toArray();
},
/**
* Builds a char code to unicode map based on section 9.10 of the spec.
* @param {Object} properties Font properties object.
* @return {Object} A ToUnicodeMap object.
*/
buildToUnicode: function Font_buildToUnicode(properties) {
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
return properties.toUnicode;
}
// According to the spec if the font is a simple font we should only map
// to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
// the differences array only contains adobe standard or symbol set names,
// in pratice it seems better to always try to create a toUnicode
// map based of the default encoding.
var toUnicode, charcode;
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
encoding[charcode] = differences[charcode];
}
var glyphsUnicodeMap = getGlyphsUnicode();
for (charcode in encoding) {
// a) Map the character code to a character name.
var glyphName = encoding[charcode];
// b) Look up the character name in the Adobe Glyph List (see the
// Bibliography) to obtain the corresponding Unicode value.
if (glyphName === '') {
continue;
} else if (glyphsUnicodeMap[glyphName] === undefined) {
// (undocumented) c) Few heuristics to recognize unknown glyphs
// NOTE: Adobe Reader does not do this step, but OSX Preview does
var code = 0;
switch (glyphName[0]) {
case 'G': // Gxx glyph
if (glyphName.length === 3) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'g': // g00xx glyph
if (glyphName.length === 5) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'C': // Cddd glyph
case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
default:
// 'uniXXXX'/'uXXXX{XX}' glyphs
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
code = unicode;
}
}
if (code) {
// If |baseEncodingName| is one the predefined encodings,
// and |code| equals |charcode|, using the glyph defined in the
// baseEncoding seems to yield a better |toUnicode| mapping
// (fixes issue 5070).
if (baseEncodingName && code === +charcode) {
var baseEncoding = getEncoding(baseEncodingName);
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
}
continue;
}
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
}
return new ToUnicodeMap(toUnicode);
}
// If the font is a composite font that uses one of the predefined CMaps
// listed in Table 118 (except Identity–H and Identity–V) or whose
// descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
// Adobe-Korea1 character collection:
if (properties.composite && (
(properties.cMap.builtInCMap &&
!(properties.cMap instanceof IdentityCMap)) ||
(properties.cidSystemInfo.registry === 'Adobe' &&
(properties.cidSystemInfo.ordering === 'GB1' ||
properties.cidSystemInfo.ordering === 'CNS1' ||
properties.cidSystemInfo.ordering === 'Japan1' ||
properties.cidSystemInfo.ordering === 'Korea1')))) {
// Then:
// a) Map the character code to a character identifier (CID) according
// to the font’s CMap.
// b) Obtain the registry and ordering of the character collection used
// by the font’s CMap (for example, Adobe and Japan1) from its
// CIDSystemInfo dictionary.
var registry = properties.cidSystemInfo.registry;
var ordering = properties.cidSystemInfo.ordering;
// c) Construct a second CMap name by concatenating the registry and
// ordering obtained in step (b) in the format registry–ordering–UCS2
// (for example, Adobe–Japan1–UCS2).
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
// d) Obtain the CMap with the name constructed in step (c) (available
// from the ASN Web site; see the Bibliography).
var ucs2CMap = CMapFactory.create(ucs2CMapName,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
var cMap = properties.cMap;
toUnicode = [];
cMap.forEach(function(charcode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
// e) Map the CID obtained in step (a) according to the CMap obtained
// in step (d), producing a Unicode value.
var ucs2 = ucs2CMap.lookup(cid);
if (ucs2) {
toUnicode[charcode] =
String.fromCharCode((ucs2.charCodeAt(0) << 8) +
ucs2.charCodeAt(1));
}
});
return new ToUnicodeMap(toUnicode);
}
// The viewer's choice, just use an identity map.
return new IdentityToUnicodeMap(properties.firstChar,
properties.lastChar);
},
get spaceWidth() {
if ('_shadowWidth' in this) {
return this._shadowWidth;
@ -44901,12 +44775,13 @@ exports.getTilingPatternIR = getTilingPatternIR; @@ -44901,12 +44775,13 @@ exports.getTilingPatternIR = getTilingPatternIR;
root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern,
root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi,
root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts,
root.pdfjsCoreUnicode);
root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
}
}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser,
coreImage, coreColorSpace, coreMurmurHash3, coreFonts,
coreFunction, corePattern, coreCMap, coreMetrics, coreBidi,
coreEncodings, coreStandardFonts, coreUnicode) {
coreEncodings, coreStandardFonts, coreUnicode,
coreGlyphList) {
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
@ -44964,6 +44839,8 @@ var getSerifFonts = coreStandardFonts.getSerifFonts; @@ -44964,6 +44839,8 @@ var getSerifFonts = coreStandardFonts.getSerifFonts;
var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
var reverseIfRtl = coreUnicode.reverseIfRtl;
var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
var PartialEvaluator = (function PartialEvaluatorClosure() {
function PartialEvaluator(pdfManager, xref, handler, pageIndex,
@ -45512,8 +45389,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -45512,8 +45389,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// TODO move promises into translate font
var translatedPromise;
try {
translatedPromise = Promise.resolve(
this.translateFont(preEvaluatedFont, xref));
translatedPromise = this.translateFont(preEvaluatedFont, xref);
} catch (e) {
translatedPromise = Promise.reject(e);
}
@ -46411,9 +46287,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46411,9 +46287,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
xref, properties) {
// 9.10.2
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
if (toUnicode) {
properties.toUnicode = this.readToUnicode(toUnicode);
}
var toUnicodePromise = toUnicode ?
this.readToUnicode(toUnicode) : Promise.resolve(undefined);
if (properties.composite) {
// CIDSystemInfo helps to match CID to glyphs
var cidSystemInfo = dict.get('CIDSystemInfo');
@ -46498,20 +46374,164 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46498,20 +46374,164 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
properties.differences = differences;
properties.baseEncodingName = baseEncodingName;
properties.dict = dict;
return toUnicodePromise.then(function(toUnicode) {
properties.toUnicode = toUnicode;
return this.buildToUnicode(properties);
}.bind(this)).then(function (toUnicode) {
properties.toUnicode = toUnicode;
return properties;
});
},
/**
* Builds a char code to unicode map based on section 9.10 of the spec.
* @param {Object} properties Font properties object.
* @return {Promise} A Promise resolving to ToUnicodeMap object.
*/
buildToUnicode: function partialEvaluator_buildToUnicode(properties) {
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
return Promise.resolve(properties.toUnicode);
}
// According to the spec if the font is a simple font we should only map
// to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
// the differences array only contains adobe standard or symbol set names,
// in pratice it seems better to always try to create a toUnicode
// map based of the default encoding.
var toUnicode, charcode;
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
encoding[charcode] = differences[charcode];
}
var glyphsUnicodeMap = getGlyphsUnicode();
for (charcode in encoding) {
// a) Map the character code to a character name.
var glyphName = encoding[charcode];
// b) Look up the character name in the Adobe Glyph List (see the
// Bibliography) to obtain the corresponding Unicode value.
if (glyphName === '') {
continue;
} else if (glyphsUnicodeMap[glyphName] === undefined) {
// (undocumented) c) Few heuristics to recognize unknown glyphs
// NOTE: Adobe Reader does not do this step, but OSX Preview does
var code = 0;
switch (glyphName[0]) {
case 'G': // Gxx glyph
if (glyphName.length === 3) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'g': // g00xx glyph
if (glyphName.length === 5) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'C': // Cddd glyph
case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
default:
// 'uniXXXX'/'uXXXX{XX}' glyphs
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
code = unicode;
}
}
if (code) {
// If |baseEncodingName| is one the predefined encodings,
// and |code| equals |charcode|, using the glyph defined in the
// baseEncoding seems to yield a better |toUnicode| mapping
// (fixes issue 5070).
if (baseEncodingName && code === +charcode) {
var baseEncoding = getEncoding(baseEncodingName);
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
}
continue;
}
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
}
return Promise.resolve(new ToUnicodeMap(toUnicode));
}
// If the font is a composite font that uses one of the predefined CMaps
// listed in Table 118 (except Identity–H and Identity–V) or whose
// descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
// Adobe-Korea1 character collection:
if (properties.composite && (
(properties.cMap.builtInCMap &&
!(properties.cMap instanceof IdentityCMap)) ||
(properties.cidSystemInfo.registry === 'Adobe' &&
(properties.cidSystemInfo.ordering === 'GB1' ||
properties.cidSystemInfo.ordering === 'CNS1' ||
properties.cidSystemInfo.ordering === 'Japan1' ||
properties.cidSystemInfo.ordering === 'Korea1')))) {
// Then:
// a) Map the character code to a character identifier (CID) according
// to the font’s CMap.
// b) Obtain the registry and ordering of the character collection used
// by the font’s CMap (for example, Adobe and Japan1) from its
// CIDSystemInfo dictionary.
var registry = properties.cidSystemInfo.registry;
var ordering = properties.cidSystemInfo.ordering;
// c) Construct a second CMap name by concatenating the registry and
// ordering obtained in step (b) in the format registry–ordering–UCS2
// (for example, Adobe–Japan1–UCS2).
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
// d) Obtain the CMap with the name constructed in step (c) (available
// from the ASN Web site; see the Bibliography).
return CMapFactory.create(ucs2CMapName,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (ucs2CMap) {
var cMap = properties.cMap;
toUnicode = [];
cMap.forEach(function(charcode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
// e) Map the CID obtained in step (a) according to the CMap
// obtained in step (d), producing a Unicode value.
var ucs2 = ucs2CMap.lookup(cid);
if (ucs2) {
toUnicode[charcode] =
String.fromCharCode((ucs2.charCodeAt(0) << 8) +
ucs2.charCodeAt(1));
}
});
return new ToUnicodeMap(toUnicode);
});
}
// The viewer's choice, just use an identity map.
return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar,
properties.lastChar));
},
readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
var cmap, cmapObj = toUnicode;
var cmapObj = toUnicode;
if (isName(cmapObj)) {
cmap = CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
return CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xFFFF);
}
return new ToUnicodeMap(cmap.getMap());
});
} else if (isStream(cmapObj)) {
cmap = CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
return CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xFFFF);
}
@ -46534,8 +46554,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46534,8 +46554,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
map[charCode] = String.fromCharCode.apply(String, str);
});
return new ToUnicodeMap(map);
});
}
return null;
return Promise.resolve(null);
},
readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
@ -46839,10 +46860,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46839,10 +46860,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
firstChar: 0,
lastChar: maxCharIndex
};
this.extractDataStructures(dict, dict, xref, properties);
return this.extractDataStructures(dict, dict, xref, properties).then(
function (properties) {
properties.widths = this.buildCharCodeToWidth(metrics.widths,
properties);
return new Font(baseFontName, null, properties);
}.bind(this));
}
}
@ -46919,16 +46942,25 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46919,16 +46942,25 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
coded: false
};
var cMapPromise;
if (composite) {
var cidEncoding = baseDict.get('Encoding');
if (isName(cidEncoding)) {
properties.cidEncoding = cidEncoding.name;
}
properties.cMap = CMapFactory.create(cidEncoding,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
cMapPromise = CMapFactory.create(cidEncoding,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cMap) {
properties.cMap = cMap;
properties.vertical = properties.cMap.vertical;
});
} else {
cMapPromise = Promise.resolve(undefined);
}
this.extractDataStructures(dict, baseDict, xref, properties);
return cMapPromise.then(function () {
return this.extractDataStructures(dict, baseDict, xref, properties);
}.bind(this)).then(function (properties) {
this.extractWidths(dict, xref, descriptor, properties);
if (type === 'Type3') {
@ -46936,6 +46968,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -46936,6 +46968,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
return new Font(fontName.name, fontFile, properties);
}.bind(this));
}
};

4
build/pdf.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.4.141';
var pdfjsBuild = '7ad8f3a';
var pdfjsVersion = '1.4.143';
var pdfjsBuild = '21ed8ff';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?

435
build/pdf.worker.js vendored

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.4.141';
var pdfjsBuild = '7ad8f3a';
var pdfjsVersion = '1.4.143';
var pdfjsBuild = '21ed8ff';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -25001,31 +25001,22 @@ var IdentityCMap = (function IdentityCMapClosure() { @@ -25001,31 +25001,22 @@ var IdentityCMap = (function IdentityCMapClosure() {
var BinaryCMapReader = (function BinaryCMapReaderClosure() {
function fetchBinaryData(url) {
var nonBinaryRequest = PDFJS.disableWorker;
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.open('GET', url, false);
if (!nonBinaryRequest) {
try {
request.open('GET', url, true);
request.responseType = 'arraybuffer';
nonBinaryRequest = request.responseType !== 'arraybuffer';
} catch (e) {
nonBinaryRequest = true;
}
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE) {
if (!request.response || request.status !== 200 &&
request.status !== 0) {
reject(new Error('Unable to get binary cMap at: ' + url));
} else {
resolve(new Uint8Array(request.response));
}
if (nonBinaryRequest && request.overrideMimeType) {
request.overrideMimeType('text/plain; charset=x-user-defined');
}
};
request.send(null);
if (nonBinaryRequest ? !request.responseText : !request.response) {
error('Unable to get binary cMap at: ' + url);
}
if (nonBinaryRequest) {
var data = Array.prototype.map.call(request.responseText, function (ch) {
return ch.charCodeAt(0) & 255;
});
return new Uint8Array(data);
}
return new Uint8Array(request.response);
}
function hexToInt(a, size) {
@ -25148,9 +25139,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -25148,9 +25139,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
};
function processBinaryCMap(url, cMap, extend) {
var data = fetchBinaryData(url);
return fetchBinaryData(url).then(function (data) {
var stream = new BinaryCMapStream(data);
var header = stream.readByte();
cMap.vertical = !!(header & 1);
@ -25249,8 +25239,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -25249,8 +25239,8 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
stream.readHexNumber(end, dataSize);
addHex(end, start, dataSize);
code = stream.readNumber();
cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize),
code);
cMap.mapCidRange(hexToInt(start, dataSize),
hexToInt(end, dataSize), code);
}
break;
case 4: // bfchar
@ -25302,9 +25292,10 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { @@ -25302,9 +25292,10 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
}
if (useCMap) {
extend(useCMap);
return extend(useCMap);
}
return cMap;
});
}
function BinaryCMapReader() {}
@ -25513,12 +25504,16 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -25513,12 +25504,16 @@ var CMapFactory = (function CMapFactoryClosure() {
useCMap = embededUseCMap;
}
if (useCMap) {
extendCMap(cMap, builtInCMapParams, useCMap);
return extendCMap(cMap, builtInCMapParams, useCMap);
} else {
return Promise.resolve(cMap);
}
}
function extendCMap(cMap, builtInCMapParams, useCMap) {
cMap.useCMap = createBuiltInCMap(useCMap, builtInCMapParams);
return createBuiltInCMap(useCMap, builtInCMapParams).then(
function(newCMap) {
cMap.useCMap = newCMap;
// If there aren't any code space ranges defined clone all the parent ones
// into this cMap.
if (cMap.numCodespaceRanges === 0) {
@ -25535,25 +25530,27 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -25535,25 +25530,27 @@ var CMapFactory = (function CMapFactoryClosure() {
cMap.mapOne(key, cMap.useCMap.lookup(key));
}
});
return cMap;
});
}
function parseBinaryCMap(name, builtInCMapParams) {
var url = builtInCMapParams.url + name + '.bcmap';
var cMap = new CMap(true);
new BinaryCMapReader().read(url, cMap, function (useCMap) {
extendCMap(cMap, builtInCMapParams, useCMap);
return new BinaryCMapReader().read(url, cMap, function (useCMap) {
return extendCMap(cMap, builtInCMapParams, useCMap);
});
return cMap;
}
function createBuiltInCMap(name, builtInCMapParams) {
if (name === 'Identity-H') {
return new IdentityCMap(false, 2);
return Promise.resolve(new IdentityCMap(false, 2));
} else if (name === 'Identity-V') {
return new IdentityCMap(true, 2);
return Promise.resolve(new IdentityCMap(true, 2));
}
if (BUILT_IN_CMAPS.indexOf(name) === -1) {
error('Unknown cMap name: ' + name);
return Promise.reject(new Error('Unknown cMap name: ' + name));
}
assert(builtInCMapParams, 'built-in cMap parameters are not provided');
@ -25561,17 +25558,28 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -25561,17 +25558,28 @@ var CMapFactory = (function CMapFactoryClosure() {
return parseBinaryCMap(name, builtInCMapParams);
}
var request = new XMLHttpRequest();
return new Promise(function (resolve, reject) {
var url = builtInCMapParams.url + name;
request.open('GET', url, false);
request.send(null);
if (!request.responseText) {
error('Unable to get cMap at: ' + url);
}
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE) {
if (request.status === 200 || request.status === 0) {
var cMap = new CMap(true);
var lexer = new Lexer(new StringStream(request.responseText));
parseCMap(cMap, lexer, builtInCMapParams, null);
return cMap;
parseCMap(cMap, lexer, builtInCMapParams, null).then(
function (parsedCMap) {
resolve(parsedCMap);
}).catch(function (e) {
reject(new Error({ message: 'Invalid CMap data', error: e }));
});
} else {
reject(new Error('Unable to get cMap at: ' + url));
}
}
};
request.open('GET', url, true);
request.send(null);
});
}
return {
@ -25581,17 +25589,15 @@ var CMapFactory = (function CMapFactoryClosure() { @@ -25581,17 +25589,15 @@ var CMapFactory = (function CMapFactoryClosure() {
} else if (isStream(encoding)) {
var cMap = new CMap();
var lexer = new Lexer(encoding);
try {
parseCMap(cMap, lexer, builtInCMapParams, useCMap);
} catch (e) {
warn('Invalid CMap data. ' + e);
}
if (cMap.isIdentityCMap) {
return createBuiltInCMap(cMap.name, builtInCMapParams);
return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(
function (parsedCMap) {
if (parsedCMap.isIdentityCMap) {
return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
}
return cMap;
return parsedCMap;
});
}
error('Encoding required.');
return Promise.reject(new Error('Encoding required.'));
}
};
})();
@ -26294,7 +26300,7 @@ var Font = (function FontClosure() { @@ -26294,7 +26300,7 @@ var Font = (function FontClosure() {
this.fontMatrix = properties.fontMatrix;
this.bbox = properties.bbox;
this.toUnicode = properties.toUnicode = this.buildToUnicode(properties);
this.toUnicode = properties.toUnicode;
this.toFontChar = [];
@ -28458,138 +28464,6 @@ var Font = (function FontClosure() { @@ -28458,138 +28464,6 @@ var Font = (function FontClosure() {
return builder.toArray();
},
/**
* Builds a char code to unicode map based on section 9.10 of the spec.
* @param {Object} properties Font properties object.
* @return {Object} A ToUnicodeMap object.
*/
buildToUnicode: function Font_buildToUnicode(properties) {
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
return properties.toUnicode;
}
// According to the spec if the font is a simple font we should only map
// to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
// the differences array only contains adobe standard or symbol set names,
// in pratice it seems better to always try to create a toUnicode
// map based of the default encoding.
var toUnicode, charcode;
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
encoding[charcode] = differences[charcode];
}
var glyphsUnicodeMap = getGlyphsUnicode();
for (charcode in encoding) {
// a) Map the character code to a character name.
var glyphName = encoding[charcode];
// b) Look up the character name in the Adobe Glyph List (see the
// Bibliography) to obtain the corresponding Unicode value.
if (glyphName === '') {
continue;
} else if (glyphsUnicodeMap[glyphName] === undefined) {
// (undocumented) c) Few heuristics to recognize unknown glyphs
// NOTE: Adobe Reader does not do this step, but OSX Preview does
var code = 0;
switch (glyphName[0]) {
case 'G': // Gxx glyph
if (glyphName.length === 3) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'g': // g00xx glyph
if (glyphName.length === 5) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'C': // Cddd glyph
case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
default:
// 'uniXXXX'/'uXXXX{XX}' glyphs
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
code = unicode;
}
}
if (code) {
// If |baseEncodingName| is one the predefined encodings,
// and |code| equals |charcode|, using the glyph defined in the
// baseEncoding seems to yield a better |toUnicode| mapping
// (fixes issue 5070).
if (baseEncodingName && code === +charcode) {
var baseEncoding = getEncoding(baseEncodingName);
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
}
continue;
}
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
}
return new ToUnicodeMap(toUnicode);
}
// If the font is a composite font that uses one of the predefined CMaps
// listed in Table 118 (except Identity–H and Identity–V) or whose
// descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
// Adobe-Korea1 character collection:
if (properties.composite && (
(properties.cMap.builtInCMap &&
!(properties.cMap instanceof IdentityCMap)) ||
(properties.cidSystemInfo.registry === 'Adobe' &&
(properties.cidSystemInfo.ordering === 'GB1' ||
properties.cidSystemInfo.ordering === 'CNS1' ||
properties.cidSystemInfo.ordering === 'Japan1' ||
properties.cidSystemInfo.ordering === 'Korea1')))) {
// Then:
// a) Map the character code to a character identifier (CID) according
// to the font’s CMap.
// b) Obtain the registry and ordering of the character collection used
// by the font’s CMap (for example, Adobe and Japan1) from its
// CIDSystemInfo dictionary.
var registry = properties.cidSystemInfo.registry;
var ordering = properties.cidSystemInfo.ordering;
// c) Construct a second CMap name by concatenating the registry and
// ordering obtained in step (b) in the format registry–ordering–UCS2
// (for example, Adobe–Japan1–UCS2).
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
// d) Obtain the CMap with the name constructed in step (c) (available
// from the ASN Web site; see the Bibliography).
var ucs2CMap = CMapFactory.create(ucs2CMapName,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
var cMap = properties.cMap;
toUnicode = [];
cMap.forEach(function(charcode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
// e) Map the CID obtained in step (a) according to the CMap obtained
// in step (d), producing a Unicode value.
var ucs2 = ucs2CMap.lookup(cid);
if (ucs2) {
toUnicode[charcode] =
String.fromCharCode((ucs2.charCodeAt(0) << 8) +
ucs2.charCodeAt(1));
}
});
return new ToUnicodeMap(toUnicode);
}
// The viewer's choice, just use an identity map.
return new IdentityToUnicodeMap(properties.firstChar,
properties.lastChar);
},
get spaceWidth() {
if ('_shadowWidth' in this) {
return this._shadowWidth;
@ -36917,12 +36791,13 @@ exports.getTilingPatternIR = getTilingPatternIR; @@ -36917,12 +36791,13 @@ exports.getTilingPatternIR = getTilingPatternIR;
root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern,
root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi,
root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts,
root.pdfjsCoreUnicode);
root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
}
}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser,
coreImage, coreColorSpace, coreMurmurHash3, coreFonts,
coreFunction, corePattern, coreCMap, coreMetrics, coreBidi,
coreEncodings, coreStandardFonts, coreUnicode) {
coreEncodings, coreStandardFonts, coreUnicode,
coreGlyphList) {
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
@ -36980,6 +36855,8 @@ var getSerifFonts = coreStandardFonts.getSerifFonts; @@ -36980,6 +36855,8 @@ var getSerifFonts = coreStandardFonts.getSerifFonts;
var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
var reverseIfRtl = coreUnicode.reverseIfRtl;
var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
var PartialEvaluator = (function PartialEvaluatorClosure() {
function PartialEvaluator(pdfManager, xref, handler, pageIndex,
@ -37528,8 +37405,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -37528,8 +37405,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// TODO move promises into translate font
var translatedPromise;
try {
translatedPromise = Promise.resolve(
this.translateFont(preEvaluatedFont, xref));
translatedPromise = this.translateFont(preEvaluatedFont, xref);
} catch (e) {
translatedPromise = Promise.reject(e);
}
@ -38427,9 +38303,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38427,9 +38303,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
xref, properties) {
// 9.10.2
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
if (toUnicode) {
properties.toUnicode = this.readToUnicode(toUnicode);
}
var toUnicodePromise = toUnicode ?
this.readToUnicode(toUnicode) : Promise.resolve(undefined);
if (properties.composite) {
// CIDSystemInfo helps to match CID to glyphs
var cidSystemInfo = dict.get('CIDSystemInfo');
@ -38514,20 +38390,164 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38514,20 +38390,164 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
properties.differences = differences;
properties.baseEncodingName = baseEncodingName;
properties.dict = dict;
return toUnicodePromise.then(function(toUnicode) {
properties.toUnicode = toUnicode;
return this.buildToUnicode(properties);
}.bind(this)).then(function (toUnicode) {
properties.toUnicode = toUnicode;
return properties;
});
},
/**
* Builds a char code to unicode map based on section 9.10 of the spec.
* @param {Object} properties Font properties object.
* @return {Promise} A Promise resolving to ToUnicodeMap object.
*/
buildToUnicode: function partialEvaluator_buildToUnicode(properties) {
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
return Promise.resolve(properties.toUnicode);
}
// According to the spec if the font is a simple font we should only map
// to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
// the differences array only contains adobe standard or symbol set names,
// in pratice it seems better to always try to create a toUnicode
// map based of the default encoding.
var toUnicode, charcode;
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
encoding[charcode] = differences[charcode];
}
var glyphsUnicodeMap = getGlyphsUnicode();
for (charcode in encoding) {
// a) Map the character code to a character name.
var glyphName = encoding[charcode];
// b) Look up the character name in the Adobe Glyph List (see the
// Bibliography) to obtain the corresponding Unicode value.
if (glyphName === '') {
continue;
} else if (glyphsUnicodeMap[glyphName] === undefined) {
// (undocumented) c) Few heuristics to recognize unknown glyphs
// NOTE: Adobe Reader does not do this step, but OSX Preview does
var code = 0;
switch (glyphName[0]) {
case 'G': // Gxx glyph
if (glyphName.length === 3) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'g': // g00xx glyph
if (glyphName.length === 5) {
code = parseInt(glyphName.substr(1), 16);
}
break;
case 'C': // Cddd glyph
case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
default:
// 'uniXXXX'/'uXXXX{XX}' glyphs
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
code = unicode;
}
}
if (code) {
// If |baseEncodingName| is one the predefined encodings,
// and |code| equals |charcode|, using the glyph defined in the
// baseEncoding seems to yield a better |toUnicode| mapping
// (fixes issue 5070).
if (baseEncodingName && code === +charcode) {
var baseEncoding = getEncoding(baseEncodingName);
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
}
continue;
}
toUnicode[charcode] =
String.fromCharCode(glyphsUnicodeMap[glyphName]);
}
return Promise.resolve(new ToUnicodeMap(toUnicode));
}
// If the font is a composite font that uses one of the predefined CMaps
// listed in Table 118 (except Identity–H and Identity–V) or whose
// descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
// Adobe-Korea1 character collection:
if (properties.composite && (
(properties.cMap.builtInCMap &&
!(properties.cMap instanceof IdentityCMap)) ||
(properties.cidSystemInfo.registry === 'Adobe' &&
(properties.cidSystemInfo.ordering === 'GB1' ||
properties.cidSystemInfo.ordering === 'CNS1' ||
properties.cidSystemInfo.ordering === 'Japan1' ||
properties.cidSystemInfo.ordering === 'Korea1')))) {
// Then:
// a) Map the character code to a character identifier (CID) according
// to the font’s CMap.
// b) Obtain the registry and ordering of the character collection used
// by the font’s CMap (for example, Adobe and Japan1) from its
// CIDSystemInfo dictionary.
var registry = properties.cidSystemInfo.registry;
var ordering = properties.cidSystemInfo.ordering;
// c) Construct a second CMap name by concatenating the registry and
// ordering obtained in step (b) in the format registry–ordering–UCS2
// (for example, Adobe–Japan1–UCS2).
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
// d) Obtain the CMap with the name constructed in step (c) (available
// from the ASN Web site; see the Bibliography).
return CMapFactory.create(ucs2CMapName,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (ucs2CMap) {
var cMap = properties.cMap;
toUnicode = [];
cMap.forEach(function(charcode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
// e) Map the CID obtained in step (a) according to the CMap
// obtained in step (d), producing a Unicode value.
var ucs2 = ucs2CMap.lookup(cid);
if (ucs2) {
toUnicode[charcode] =
String.fromCharCode((ucs2.charCodeAt(0) << 8) +
ucs2.charCodeAt(1));
}
});
return new ToUnicodeMap(toUnicode);
});
}
// The viewer's choice, just use an identity map.
return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar,
properties.lastChar));
},
readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
var cmap, cmapObj = toUnicode;
var cmapObj = toUnicode;
if (isName(cmapObj)) {
cmap = CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
return CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xFFFF);
}
return new ToUnicodeMap(cmap.getMap());
});
} else if (isStream(cmapObj)) {
cmap = CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
return CMapFactory.create(cmapObj,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xFFFF);
}
@ -38550,8 +38570,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38550,8 +38570,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
map[charCode] = String.fromCharCode.apply(String, str);
});
return new ToUnicodeMap(map);
});
}
return null;
return Promise.resolve(null);
},
readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
@ -38855,10 +38876,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38855,10 +38876,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
firstChar: 0,
lastChar: maxCharIndex
};
this.extractDataStructures(dict, dict, xref, properties);
return this.extractDataStructures(dict, dict, xref, properties).then(
function (properties) {
properties.widths = this.buildCharCodeToWidth(metrics.widths,
properties);
return new Font(baseFontName, null, properties);
}.bind(this));
}
}
@ -38935,16 +38958,25 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38935,16 +38958,25 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
coded: false
};
var cMapPromise;
if (composite) {
var cidEncoding = baseDict.get('Encoding');
if (isName(cidEncoding)) {
properties.cidEncoding = cidEncoding.name;
}
properties.cMap = CMapFactory.create(cidEncoding,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
cMapPromise = CMapFactory.create(cidEncoding,
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
function (cMap) {
properties.cMap = cMap;
properties.vertical = properties.cMap.vertical;
});
} else {
cMapPromise = Promise.resolve(undefined);
}
this.extractDataStructures(dict, baseDict, xref, properties);
return cMapPromise.then(function () {
return this.extractDataStructures(dict, baseDict, xref, properties);
}.bind(this)).then(function (properties) {
this.extractWidths(dict, xref, descriptor, properties);
if (type === 'Type3') {
@ -38952,6 +38984,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38952,6 +38984,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
return new Font(fontName.name, fontFile, properties);
}.bind(this));
}
};

2
package.json

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

Loading…
Cancel
Save