Fix for PDF accessibility check. (#1265)

This commit is contained in:
adrift2000 2021-06-23 01:48:53 +10:00 committed by GitHub
parent 131df9e0ae
commit 4700537d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 19 deletions

View File

@ -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();
}
}

View File

@ -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`
]);