@jsreport/pdfjs
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -13,2 +13,6 @@ const PDF = require('../object') | ||
for (const { title, parent, id } of aoutlines) { | ||
if (!doc.catalog.properties.get('Dests').object.properties.get(id)) { | ||
continue | ||
} | ||
const outline = new PDF.Object() | ||
@@ -15,0 +19,0 @@ outline.data = { title, id, parent } |
@@ -23,2 +23,6 @@ const PDF = require('../../object') | ||
if (ext.catalog.properties.get('Outlines')?.object && doc.catalog.properties.get('Outlines') == null) { | ||
doc.catalog.properties.set('Outlines', ext.catalog.properties.get('Outlines').object.toReference()) | ||
} | ||
if (options.copyAccessibilityTags) { | ||
@@ -25,0 +29,0 @@ mergeStructTree(ext, doc) |
{ | ||
"name": "@jsreport/pdfjs", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -377,2 +377,30 @@ const { Document, External } = require('../') | ||
it('append should copy outliness', async () => { | ||
let document = new Document() | ||
let external = new External(fs.readFileSync(path.join(__dirname, 'links.pdf'))) | ||
document.append(external) | ||
document.outlines([{ | ||
title: '1 title', | ||
id: '1' | ||
}, { | ||
title: '2 title', | ||
id: '2', | ||
parent: '1' | ||
}]) | ||
const pdfWithOutlines = await document.asBuffer() | ||
document = new Document() | ||
external = new External(pdfWithOutlines) | ||
document.append(external) | ||
const pdfBuffer = await document.asBuffer() | ||
require('fs').writeFileSync('out.pdf', pdfBuffer) | ||
const { catalog } = await validate(pdfBuffer) | ||
const outlines = catalog.properties.get('Outlines').object | ||
const outline1 = outlines.properties.get('First').object | ||
outlines.properties.get('Last').object.should.be.eql(outline1) | ||
}) | ||
it('merge should union Dests', async () => { | ||
@@ -379,0 +407,0 @@ const document = new Document() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2687972
6168
7