mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Merge pull request #9931 from Snuffleupagus/refactor-getPage
Refactor `getPage` (in the worker), and attempt to use the `Linearization` dictionary to lookup the first Page
This commit is contained in:
commit
f45450bd78
2 changed files with 51 additions and 37 deletions
|
@ -29,7 +29,7 @@ import { CipherTransformFactory } from './crypto';
|
|||
import { ColorSpace } from './colorspace';
|
||||
|
||||
var Catalog = (function CatalogClosure() {
|
||||
function Catalog(pdfManager, xref, pageFactory) {
|
||||
function Catalog(pdfManager, xref) {
|
||||
this.pdfManager = pdfManager;
|
||||
this.xref = xref;
|
||||
this.catDict = xref.getCatalogObj();
|
||||
|
@ -40,9 +40,6 @@ var Catalog = (function CatalogClosure() {
|
|||
this.fontCache = new RefSetCache();
|
||||
this.builtInCMapCache = new Map();
|
||||
this.pageKidsCountCache = new RefSetCache();
|
||||
// TODO refactor to move getPage() to the PDFDocument.
|
||||
this.pageFactory = pageFactory;
|
||||
this.pagePromises = [];
|
||||
}
|
||||
|
||||
Catalog.prototype = {
|
||||
|
@ -453,18 +450,6 @@ var Catalog = (function CatalogClosure() {
|
|||
});
|
||||
},
|
||||
|
||||
getPage: function Catalog_getPage(pageIndex) {
|
||||
if (!(pageIndex in this.pagePromises)) {
|
||||
this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(
|
||||
([dict, ref]) => {
|
||||
return this.pageFactory.createPage(pageIndex, dict, ref,
|
||||
this.fontCache,
|
||||
this.builtInCMapCache);
|
||||
});
|
||||
}
|
||||
return this.pagePromises[pageIndex];
|
||||
},
|
||||
|
||||
getPageDict: function Catalog_getPageDict(pageIndex) {
|
||||
var capability = createPromiseCapability();
|
||||
var nodesToVisit = [this.catDict.getRaw('Pages')];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue