-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for PDF/A-2 and PDF/A-3 subsets (#1432)
* Added PDF/A-2 and PDF/A-3 subsets A and B It seems like PDF/A-2 and PDF/A-3 are not very different from PDF/A-1 as far as the A and B subsets are concerned (A requires tagging which PDFKit supports already). With this change, we can let the generated PDF present itself as PDF/A-2 or PDF/A-3. * Updated docs and changelog for new PDF/A subsets * Fixed an issue where ICC profile path can be wrong for built package but good for tests
- Loading branch information
1 parent
d81f13b
commit c1d7700
Showing
6 changed files
with
210 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
import PDFA1 from './pdfa1'; | ||
// import PDFA2 from './pdfa2'; | ||
import PDFA from './pdfa'; | ||
|
||
export default { | ||
_importSubset(subset) { | ||
Object.assign(this, subset) | ||
}, | ||
|
||
initSubset(options) { | ||
|
||
switch (options.subset) { | ||
case 'PDF/A-1': | ||
case 'PDF/A-1a': | ||
case 'PDF/A-1b': | ||
this._importSubset(PDFA1); | ||
this.initPDFA1(options); | ||
case 'PDF/A-2': | ||
case 'PDF/A-2a': | ||
case 'PDF/A-2b': | ||
case 'PDF/A-3': | ||
case 'PDF/A-3a': | ||
case 'PDF/A-3b': | ||
this._importSubset(PDFA); | ||
this.initPDFA(options.subset); | ||
break; | ||
// case 'PDF/A-2': | ||
// case 'PDF/A-2a': | ||
// case 'PDF/A-2b': | ||
// case 'PDF/A-2u': | ||
// this._importSubset(PDFA2); | ||
// this.initPDFA2(options); | ||
// break; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PDFDocument from '../../lib/document'; | ||
import { logData, joinTokens } from './helpers'; | ||
|
||
describe('PDF/A-2', () => { | ||
|
||
test('metadata is present', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-2' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
expect(data).toContainChunk([ | ||
`11 0 obj`, | ||
`<<\n/length 892\n/Type /Metadata\n/Subtype /XML\n/Length 894\n>>` | ||
]); | ||
}); | ||
|
||
test('color profile is present', () => { | ||
const expected = [ | ||
`10 0 obj`, | ||
joinTokens( | ||
'<<', | ||
'/Type /OutputIntent', | ||
'/S /GTS_PDFA1', | ||
'/Info (sRGB IEC61966-2.1)', | ||
'/OutputConditionIdentifier (sRGB IEC61966-2.1)', | ||
'/DestOutputProfile 9 0 R', | ||
'>>' | ||
), | ||
]; | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-2' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
expect(data).toContainChunk(expected); | ||
}); | ||
|
||
test('metadata contains pdfaid part and conformance', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-2' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:part>2'); | ||
expect(metadata).toContain('pdfaid:conformance'); | ||
}); | ||
|
||
test('metadata pdfaid conformance B', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-2b' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:conformance>B'); | ||
}); | ||
|
||
test('metadata pdfaid conformance A', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-2a' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:conformance>A'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PDFDocument from '../../lib/document'; | ||
import { logData, joinTokens } from './helpers'; | ||
|
||
describe('PDF/A-3', () => { | ||
|
||
test('metadata is present', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-3' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
expect(data).toContainChunk([ | ||
`11 0 obj`, | ||
`<<\n/length 892\n/Type /Metadata\n/Subtype /XML\n/Length 894\n>>` | ||
]); | ||
}); | ||
|
||
test('color profile is present', () => { | ||
const expected = [ | ||
`10 0 obj`, | ||
joinTokens( | ||
'<<', | ||
'/Type /OutputIntent', | ||
'/S /GTS_PDFA1', | ||
'/Info (sRGB IEC61966-2.1)', | ||
'/OutputConditionIdentifier (sRGB IEC61966-2.1)', | ||
'/DestOutputProfile 9 0 R', | ||
'>>' | ||
), | ||
]; | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-3' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
expect(data).toContainChunk(expected); | ||
}); | ||
|
||
test('metadata contains pdfaid part and conformance', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-3' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:part>3'); | ||
expect(metadata).toContain('pdfaid:conformance'); | ||
}); | ||
|
||
test('metadata pdfaid conformance B', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-3b' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:conformance>B'); | ||
}); | ||
|
||
test('metadata pdfaid conformance A', () => { | ||
let options = { | ||
autoFirstPage: false, | ||
pdfVersion: '1.7', | ||
subset: 'PDF/A-3a' | ||
}; | ||
let doc = new PDFDocument(options); | ||
const data = logData(doc); | ||
doc.end(); | ||
let metadata = Buffer.from(data[27]).toString(); | ||
|
||
expect(metadata).toContain('pdfaid:conformance>A'); | ||
}); | ||
|
||
}); |