@jsreport/pdfjs
Advanced tools
Comparing version 0.6.2 to 0.7.0
@@ -109,5 +109,2 @@ 'use strict' | ||
// init destinations name tree | ||
this._destinations = new PDF.NameTree() | ||
// init outlines hierarchy | ||
@@ -151,2 +148,6 @@ this._outlines = [] | ||
this._acroFormObj.prop('Fields', new PDF.Array()) | ||
this._namesObj = new PDF.Object() | ||
this._namesObj.prop('EmbeddedFiles', new PDF.Dictionary()) | ||
this._namesObj.properties.get('EmbeddedFiles').set('Names', new PDF.Array()) | ||
} | ||
@@ -591,8 +592,13 @@ | ||
catalog.prop('Pages', this._pagesObj.toReference()) | ||
if (this._destinations.length > 0) { | ||
const destsObj = new PDF.Object() | ||
destsObj.prop('Dests', this._destinations) | ||
await this._writeObject(destsObj) | ||
catalog.prop('Names', destsObj.toReference()) | ||
const namesObjects = [] | ||
Parser.addObjectsRecursive(namesObjects, this._namesObj) | ||
for (const o of namesObjects) { | ||
this._registerObject(o) | ||
} | ||
for (const o of namesObjects) { | ||
this._writeObject(o) | ||
} | ||
await this._writeObject(this._namesObj) | ||
catalog.prop('Names', this._namesObj.toReference()) | ||
@@ -626,2 +632,5 @@ if (this._destsObject) { | ||
for (const o of acroFormObjects) { | ||
this._registerObject(o) | ||
} | ||
for (const o of acroFormObjects) { | ||
this._writeObject(o) | ||
@@ -628,0 +637,0 @@ } |
@@ -22,2 +22,6 @@ 'use strict' | ||
} | ||
const namesRef = this.catalog.get('Names') | ||
if (namesRef) { | ||
this.namesObj = namesRef.object | ||
} | ||
@@ -83,2 +87,15 @@ const info = parser.trailer.get('Info') | ||
if (this.namesObj) { | ||
const namesObjects = [] | ||
Parser.addObjectsRecursive(namesObjects, this.namesObj) | ||
for (const o of namesObjects) { | ||
doc._registerObject(o) | ||
} | ||
const docNames = doc._namesObj.properties.get('EmbeddedFiles').get('Names') | ||
doc._namesObj.properties.get('EmbeddedFiles').set('Names', new PDF.Array([ | ||
...(this.namesObj.properties.get('EmbeddedFiles')?.get('Names') ?? []), | ||
...docNames | ||
])) | ||
} | ||
// merge in the acroform object | ||
@@ -85,0 +102,0 @@ if (this.acroFormObj && this.acroFormObj.properties.get('Fields')) { |
{ | ||
"name": "@jsreport/pdfjs", | ||
"author": "Markus Ast <npm.m@rkusa.st>", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "A Portable Document Format (PDF) generation library targeting both the server- and client-side.", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
"scripts": { | ||
"test": "npm run test:pdfs && npm run test:types", | ||
"test:all": "npm run test:pdfs && npm run test:types", | ||
"test:pdfs": "node test/index.js", | ||
@@ -18,0 +18,0 @@ "test:types": "tsc --project ./types" |
Sorry, the diff of this file is not supported yet
7210761
349
10864