mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Cache built-in binary CMap files in the worker (issue 4794)
This commit is contained in:
parent
769c1450b7
commit
111419a64a
4 changed files with 29 additions and 9 deletions
|
@ -170,18 +170,29 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
};
|
||||
|
||||
function PartialEvaluator(pdfManager, xref, handler, pageIndex,
|
||||
idFactory, fontCache, options) {
|
||||
idFactory, fontCache, builtInCMapCache, options) {
|
||||
this.pdfManager = pdfManager;
|
||||
this.xref = xref;
|
||||
this.handler = handler;
|
||||
this.pageIndex = pageIndex;
|
||||
this.idFactory = idFactory;
|
||||
this.fontCache = fontCache;
|
||||
this.builtInCMapCache = builtInCMapCache;
|
||||
this.options = options || DefaultPartialEvaluatorOptions;
|
||||
|
||||
this.fetchBuiltInCMap = function (name) {
|
||||
var cachedCMap = builtInCMapCache[name];
|
||||
if (cachedCMap) {
|
||||
return Promise.resolve(cachedCMap);
|
||||
}
|
||||
return handler.sendWithPromise('FetchBuiltInCMap', {
|
||||
name: name,
|
||||
}).then(function (data) {
|
||||
if (data.compressionType !== CMapCompressionType.NONE) {
|
||||
// Given the size of uncompressed CMaps, only cache compressed ones.
|
||||
builtInCMapCache[name] = data;
|
||||
}
|
||||
return data;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue