pdfkit/tests/unit/pdfua.spec.js
Andrei Augustin 408dc4e9ba
Add PDF/UA subset (#1485)
* Added PDF/UA subset and its metadata

* Added PDF/UA metadata unit tests

* Added PDF/UA subset to accessibility docs

* Updated change log for PDF/UA subset
2023-12-17 16:11:46 -03:00

37 lines
996 B
JavaScript

import PDFDocument from '../../lib/document';
import { logData } from './helpers';
describe('PDF/UA', () => {
test('metadata is present', () => {
let options = {
autoFirstPage: false,
pdfVersion: '1.7',
subset: 'PDF/UA',
tagged: true
};
let doc = new PDFDocument(options);
const data = logData(doc);
doc.end();
expect(data).toContainChunk([
`11 0 obj`,
`<<\n/length 841\n/Type /Metadata\n/Subtype /XML\n/Length 843\n>>`
]);
});
test('metadata constains pdfuaid part', () => {
let options = {
autoFirstPage: false,
pdfVersion: '1.7',
subset: 'PDF/UA',
tagged: true
};
let doc = new PDFDocument(options);
const data = logData(doc);
doc.end();
let metadata = Buffer.from(data[24]).toString();
expect(metadata).toContain('pdfuaid:part>1');
});
});