Skip to content

Commit

Permalink
fix: pdf/a compliance of attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
florianbepunkt committed Nov 2, 2024
1 parent 3a6977e commit cbd8b62
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/mixins/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export default {
* * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
* * options.creationDate: override creation date
* * options.modifiedDate: override modified date
* * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
* @returns filespec reference
*/
file(src, options = {}) {
options.name = options.name || src;
options.relationship = options.relationship || 'Unspecified';

const refBody = {
Type: 'EmbeddedFile',
Expand Down Expand Up @@ -85,6 +87,7 @@ export default {
// add filespec for embedded file
const fileSpecBody = {
Type: 'Filespec',
AFRelationship: options.relationship,
F: new String(options.name),
EF: { F: ref },
UF: new String(options.name)
Expand All @@ -99,6 +102,13 @@ export default {
this.addNamedEmbeddedFile(options.name, filespec);
}

// Add file to the catalogue to be PDF/A3 compliant
if (this._root.data.AF) {
this._root.data.AF.push(filespec);
} else {
this._root.data.AF = [filespec];
}

return filespec;
}
};
Expand Down

0 comments on commit cbd8b62

Please sign in to comment.