mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
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:
parent
55d9b35d37
commit
34952b732e
7 changed files with 36 additions and 46 deletions
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue