From 3e6938d6632f986c870cd276aab44235398e9cf4 Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Sat, 23 Jul 2016 01:24:31 +0100 Subject: [PATCH] PDF.js version 1.5.351 - See mozilla/pdf.js@5678486802f24a104444d311aee0572e1153fe85 --- bower.json | 2 +- build/pdf.combined.js | 64 +++++++++++++++++++++++++++++-------------- build/pdf.js | 4 +-- build/pdf.worker.js | 64 +++++++++++++++++++++++++++++-------------- package.json | 2 +- 5 files changed, 90 insertions(+), 46 deletions(-) diff --git a/bower.json b/bower.json index 1b99886d5..08d519d55 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.5.347", + "version": "1.5.351", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 834cf9768..4d4b9ef7d 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.347'; -var pdfjsBuild = '50d6e4f'; +var pdfjsVersion = '1.5.351'; +var pdfjsBuild = '5678486'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -45775,8 +45775,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return errorFont(); } - // We are holding font.translated references just for fontRef that are not - // dictionaries (Dict). See explanation below. + // We are holding `font.translated` references just for `fontRef`s that + // are not actually `Ref`s, but rather `Dict`s. See explanation below. if (font.translated) { return font.translated; } @@ -45785,7 +45785,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var preEvaluatedFont = this.preEvaluateFont(font, xref); var descriptor = preEvaluatedFont.descriptor; - var fontID = fontRef.num + '_' + fontRef.gen; + + var fontRefIsRef = isRef(fontRef), fontID; + if (fontRefIsRef) { + fontID = fontRef.toString(); + } + if (isDict(descriptor)) { if (!descriptor.fontAliases) { descriptor.fontAliases = Object.create(null); @@ -45795,36 +45800,53 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var hash = preEvaluatedFont.hash; if (fontAliases[hash]) { var aliasFontRef = fontAliases[hash].aliasRef; - if (aliasFontRef && this.fontCache.has(aliasFontRef)) { + if (fontRefIsRef && aliasFontRef && + this.fontCache.has(aliasFontRef)) { this.fontCache.putAlias(fontRef, aliasFontRef); return this.fontCache.get(fontRef); } - } - - if (!fontAliases[hash]) { + } else { fontAliases[hash] = { fontID: Font.getFontID() }; } - fontAliases[hash].aliasRef = fontRef; + if (fontRefIsRef) { + fontAliases[hash].aliasRef = fontRef; + } fontID = fontAliases[hash].fontID; } - // Workaround for bad PDF generators that don't reference fonts - // properly, i.e. by not using an object identifier. - // Check if the fontRef is a Dict (as opposed to a standard object), - // in which case we don't cache the font and instead reference it by - // fontName in font.loadedName below. - var fontRefIsDict = isDict(fontRef); - if (!fontRefIsDict) { + // Workaround for bad PDF generators that reference fonts incorrectly, + // where `fontRef` is a `Dict` rather than a `Ref` (fixes bug946506.pdf). + // In this case we should not put the font into `this.fontCache` (which is + // a `RefSetCache`), since it's not meaningful to use a `Dict` as a key. + // + // However, if we don't cache the font it's not possible to remove it + // when `cleanup` is triggered from the API, which causes issues on + // subsequent rendering operations (see issue7403.pdf). + // A simple workaround would be to just not hold `font.translated` + // references in this case, but this would force us to unnecessarily load + // the same fonts over and over. + // + // Instead, we cheat a bit by attempting to use a modified `fontID` as a + // key in `this.fontCache`, to allow the font to be cached. + // NOTE: This works because `RefSetCache` calls `toString()` on provided + // keys. Also, since `fontRef` is used when getting cached fonts, + // we'll not accidentally match fonts cached with the `fontID`. + if (fontRefIsRef) { this.fontCache.put(fontRef, fontCapability.promise); + } else { + if (!fontID) { + fontID = (this.uniquePrefix || 'F_') + (++this.idCounters.obj); + } + this.fontCache.put('id_' + fontID, fontCapability.promise); } + assert(fontID, 'The "fontID" must be defined.'); // Keep track of each font we translated so the caller can // load them asynchronously before calling display on a page. - font.loadedName = 'g_' + this.pdfManager.docId + '_f' + (fontRefIsDict ? - fontName.replace(/\W/g, '') : fontID); + font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID; font.translated = fontCapability.promise; @@ -47234,7 +47256,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (isName(encoding)) { hash.update(encoding.name); } else if (isRef(encoding)) { - hash.update(encoding.num + '_' + encoding.gen); + hash.update(encoding.toString()); } else if (isDict(encoding)) { var keys = encoding.getKeys(); for (var i = 0, ii = keys.length; i < ii; i++) { @@ -47242,7 +47264,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (isName(entry)) { hash.update(entry.name); } else if (isRef(entry)) { - hash.update(entry.num + '_' + entry.gen); + hash.update(entry.toString()); } else if (isArray(entry)) { // 'Differences' entry. // Ideally we should check the contents of the array, but to avoid // parsing it here and then again in |extractDataStructures|, diff --git a/build/pdf.js b/build/pdf.js index d502a6809..f32768d8e 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.347'; -var pdfjsBuild = '50d6e4f'; +var pdfjsVersion = '1.5.351'; +var pdfjsBuild = '5678486'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 4b1787fab..03d7a0bbd 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.347'; -var pdfjsBuild = '50d6e4f'; +var pdfjsVersion = '1.5.351'; +var pdfjsBuild = '5678486'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -37429,8 +37429,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return errorFont(); } - // We are holding font.translated references just for fontRef that are not - // dictionaries (Dict). See explanation below. + // We are holding `font.translated` references just for `fontRef`s that + // are not actually `Ref`s, but rather `Dict`s. See explanation below. if (font.translated) { return font.translated; } @@ -37439,7 +37439,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var preEvaluatedFont = this.preEvaluateFont(font, xref); var descriptor = preEvaluatedFont.descriptor; - var fontID = fontRef.num + '_' + fontRef.gen; + + var fontRefIsRef = isRef(fontRef), fontID; + if (fontRefIsRef) { + fontID = fontRef.toString(); + } + if (isDict(descriptor)) { if (!descriptor.fontAliases) { descriptor.fontAliases = Object.create(null); @@ -37449,36 +37454,53 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var hash = preEvaluatedFont.hash; if (fontAliases[hash]) { var aliasFontRef = fontAliases[hash].aliasRef; - if (aliasFontRef && this.fontCache.has(aliasFontRef)) { + if (fontRefIsRef && aliasFontRef && + this.fontCache.has(aliasFontRef)) { this.fontCache.putAlias(fontRef, aliasFontRef); return this.fontCache.get(fontRef); } - } - - if (!fontAliases[hash]) { + } else { fontAliases[hash] = { fontID: Font.getFontID() }; } - fontAliases[hash].aliasRef = fontRef; + if (fontRefIsRef) { + fontAliases[hash].aliasRef = fontRef; + } fontID = fontAliases[hash].fontID; } - // Workaround for bad PDF generators that don't reference fonts - // properly, i.e. by not using an object identifier. - // Check if the fontRef is a Dict (as opposed to a standard object), - // in which case we don't cache the font and instead reference it by - // fontName in font.loadedName below. - var fontRefIsDict = isDict(fontRef); - if (!fontRefIsDict) { + // Workaround for bad PDF generators that reference fonts incorrectly, + // where `fontRef` is a `Dict` rather than a `Ref` (fixes bug946506.pdf). + // In this case we should not put the font into `this.fontCache` (which is + // a `RefSetCache`), since it's not meaningful to use a `Dict` as a key. + // + // However, if we don't cache the font it's not possible to remove it + // when `cleanup` is triggered from the API, which causes issues on + // subsequent rendering operations (see issue7403.pdf). + // A simple workaround would be to just not hold `font.translated` + // references in this case, but this would force us to unnecessarily load + // the same fonts over and over. + // + // Instead, we cheat a bit by attempting to use a modified `fontID` as a + // key in `this.fontCache`, to allow the font to be cached. + // NOTE: This works because `RefSetCache` calls `toString()` on provided + // keys. Also, since `fontRef` is used when getting cached fonts, + // we'll not accidentally match fonts cached with the `fontID`. + if (fontRefIsRef) { this.fontCache.put(fontRef, fontCapability.promise); + } else { + if (!fontID) { + fontID = (this.uniquePrefix || 'F_') + (++this.idCounters.obj); + } + this.fontCache.put('id_' + fontID, fontCapability.promise); } + assert(fontID, 'The "fontID" must be defined.'); // Keep track of each font we translated so the caller can // load them asynchronously before calling display on a page. - font.loadedName = 'g_' + this.pdfManager.docId + '_f' + (fontRefIsDict ? - fontName.replace(/\W/g, '') : fontID); + font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID; font.translated = fontCapability.promise; @@ -38888,7 +38910,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (isName(encoding)) { hash.update(encoding.name); } else if (isRef(encoding)) { - hash.update(encoding.num + '_' + encoding.gen); + hash.update(encoding.toString()); } else if (isDict(encoding)) { var keys = encoding.getKeys(); for (var i = 0, ii = keys.length; i < ii; i++) { @@ -38896,7 +38918,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (isName(entry)) { hash.update(entry.name); } else if (isRef(entry)) { - hash.update(entry.num + '_' + entry.gen); + hash.update(entry.toString()); } else if (isArray(entry)) { // 'Differences' entry. // Ideally we should check the contents of the array, but to avoid // parsing it here and then again in |extractDataStructures|, diff --git a/package.json b/package.json index 6675b886a..ccca5d658 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.5.347", + "version": "1.5.351", "main": "build/pdf.js", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [