Skip to content

Commit

Permalink
Fix CIDSet generation only for PDF/A1 subset #1561
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Dec 14, 2024
1 parent 8f97007 commit 75a8dbc
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix index not counting when rendering ordered lists (#1517)
- Fix PDF/A3 compliance of attachments
- Fix CIDSet generation only for PDF/A1 subset

### [v0.15.1] - 2024-10-30

Expand Down
2 changes: 1 addition & 1 deletion lib/font/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class EmbeddedFont extends PDFFont {
descriptor.data.FontFile2 = fontFile;
}

if (this.document.subset) {
if (this.document.subset && this.document.subset === 1) {
const CIDSet = Buffer.from('FFFFFFFFC0', 'hex');
const CIDSetRef = this.document.ref();
CIDSetRef.write(CIDSet);
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/pdfa1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,24 @@ describe('PDF/A-1', () => {

expect(metadata).toContain('pdfaid:conformance>A');
});

test('font data contains CIDSet', () => {
let options = {
autoFirstPage: false,
pdfVersion: '1.4',
subset: 'PDF/A-1a'
};
let doc = new PDFDocument(options);
const data = logData(doc);
doc.addPage();
doc.registerFont('Roboto', 'tests/fonts/Roboto-Regular.ttf');
doc.font('Roboto');
doc.text('Text');
doc.end();

let fontDescriptor = data[data.length-41];

expect(fontDescriptor).toContain('/CIDSet');
});

});
19 changes: 19 additions & 0 deletions tests/unit/pdfa2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,24 @@ describe('PDF/A-2', () => {

expect(metadata).toContain('pdfaid:conformance>A');
});

test('font data NOT contains CIDSet', () => {
let options = {
autoFirstPage: false,
pdfVersion: '1.4',
subset: 'PDF/A-2a'
};
let doc = new PDFDocument(options);
const data = logData(doc);
doc.addPage();
doc.registerFont('Roboto', 'tests/fonts/Roboto-Regular.ttf');
doc.font('Roboto');
doc.text('Text');
doc.end();

let fontDescriptor = data[data.length-41];

expect(fontDescriptor).not.toContain('/CIDSet');
});

});
21 changes: 20 additions & 1 deletion tests/unit/pdfa3.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,24 @@ describe('PDF/A-3', () => {

expect(metadata).toContain('pdfaid:conformance>A');
});


test('font data NOT contains CIDSet', () => {
let options = {
autoFirstPage: false,
pdfVersion: '1.4',
subset: 'PDF/A-3a'
};
let doc = new PDFDocument(options);
const data = logData(doc);
doc.addPage();
doc.registerFont('Roboto', 'tests/fonts/Roboto-Regular.ttf');
doc.font('Roboto');
doc.text('Text');
doc.end();

let fontDescriptor = data[data.length-41];

expect(fontDescriptor).not.toContain('/CIDSet');
});

});

0 comments on commit 75a8dbc

Please sign in to comment.