mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Move getPage
, on the worker side, from Catalog
and into PDFDocument
instead
Addresses an existing TODO, and avoids having to pass in a `pageFactory` when creating `Catalog` instances.
This commit is contained in:
parent
51b0e60f9b
commit
fbb25ff4e2
2 changed files with 22 additions and 33 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 = Object.create(null);
|
||||
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