Add a getDocId method to the idFactory, in Page instances, to avoid passing around PDFManager instances unnecessarily (PR 7941 follow-up)

This way we can avoid manually building a "document id" in multiple places in `evaluator.js`, and it also let's us avoid passing in an otherwise unnecessary `PDFManager` instance when creating a `PartialEvaluator`.
This commit is contained in:
Jonas Jenwald 2019-04-20 12:36:49 +02:00
parent 55d9b35d37
commit 34952b732e
7 changed files with 36 additions and 46 deletions

View file

@ -16,6 +16,7 @@
import { assert, CMapCompressionType } from '../../src/shared/util';
import isNodeJS from '../../src/shared/is_node';
import { isRef } from '../../src/core/primitives';
import { Page } from '../../src/core/document';
class DOMFileReaderFactory {
static async fetch(params) {
@ -158,6 +159,18 @@ class XRefMock {
}
}
function createIdFactory(pageIndex) {
const page = new Page({
pdfManager: {
get docId() {
return 'd0';
},
},
pageIndex,
});
return page.idFactory;
}
export {
DOMFileReaderFactory,
NodeFileReaderFactory,
@ -166,4 +179,5 @@ export {
XRefMock,
buildGetDocumentParams,
TEST_PDFS_PATH,
createIdFactory,
};