diff --git a/lib/mixins/markings.js b/lib/mixins/markings.js index 278ac7f7..589b7889 100644 --- a/lib/mixins/markings.js +++ b/lib/mixins/markings.js @@ -14,7 +14,8 @@ export default { this.structChildren = []; if (options.tagged) { - this.getMarkingsDictionary().data.Marked = true; + this.getMarkInfoDictionary().data.Marked = true; + this.getStructTreeRoot(); } }, @@ -130,17 +131,17 @@ export default { return pageMarkings; }, - getMarkingsDictionary() { - if (!this._root.data.Markings) { - this._root.data.Markings = this.ref({}); + getMarkInfoDictionary() { + if (!this._root.data.MarkInfo) { + this._root.data.MarkInfo = this.ref({}); } - return this._root.data.Markings; + return this._root.data.MarkInfo; }, getStructTreeRoot() { if (!this._root.data.StructTreeRoot) { this._root.data.StructTreeRoot = this.ref({ - Type: "StructTreeRoot", + Type: 'StructTreeRoot', ParentTree: new PDFNumberTree(), ParentTreeNextKey: 0 }); @@ -153,8 +154,8 @@ export default { }, createStructParentTreeNextKey() { - // initialise the Markings dictionary - this.getMarkingsDictionary(); + // initialise the MarkInfo dictionary + this.getMarkInfoDictionary(); const structTreeRoot = this.getStructTreeRoot(); const key = structTreeRoot.data.ParentTreeNextKey++; @@ -168,8 +169,8 @@ export default { structTreeRoot.end(); this.structChildren.forEach((structElem) => structElem.end()); } - if (this._root.data.Markings) { - this._root.data.Markings.end(); + if (this._root.data.MarkInfo) { + this._root.data.MarkInfo.end(); } } diff --git a/tests/unit/markings.spec.js b/tests/unit/markings.spec.js index acc88a42..845372f9 100644 --- a/tests/unit/markings.spec.js +++ b/tests/unit/markings.spec.js @@ -289,7 +289,7 @@ EMC ]); expect(docData).toContainChunk([ `3 0 obj`, - /\/Markings 9 0 R/, + /\/MarkInfo 9 0 R/, `endobj` ]); expect(docData).toContainChunk([ @@ -369,7 +369,7 @@ EMC ]); expect(docData).toContainChunk([ `3 0 obj`, - /\/Markings 9 0 R/, + /\/MarkInfo 9 0 R/, `endobj` ]); expect(docData).toContainChunk([ @@ -441,7 +441,7 @@ EMC ]); expect(docData).toContainChunk([ `3 0 obj`, - /\/Markings 13 0 R/, + /\/MarkInfo 13 0 R/, `endobj` ]); expect(docData).toContainChunk([ @@ -569,7 +569,7 @@ EMC ]); expect(docData).toContainChunk([ `3 0 obj`, - /\/Markings 5 0 R/, + /\/MarkInfo 5 0 R/, `endobj` ]); expect(docData).toContainChunk([ @@ -579,26 +579,47 @@ EMC ]); expect(docData).toContainChunk([ `3 0 obj`, - /\/ViewerPreferences 6 0 R/, + /\/ViewerPreferences 7 0 R/, `endobj` ]); + + expect(docData).toContainChunk([ + `3 0 obj`, + /\/StructTreeRoot 6 0 R/, + `endobj` + ]); + expect(docData).toContainChunk([ `6 0 obj`, + `<< +/Type /StructTreeRoot +/ParentTree << + /Nums [ +] +>> +/ParentTreeNextKey 0 +>>`, + `endobj` + ]); + + + expect(docData).toContainChunk([ + `7 0 obj`, /\/DisplayDocTitle true/, `endobj` ]); expect(docData).toContainChunk([ `trailer`, - /\/Info 10 0 R/, + /\/Info 11 0 R/, `startxref` ]); expect(docData).toContainChunk([ - `10 0 obj`, - /\/Title 14 0 R/, + `11 0 obj`, + /\/Title 15 0 R/, `endobj` ]); expect(docData).toContainChunk([ - `14 0 obj`, + `15 0 obj`, `(My Title)`, `endobj` ]);