Skip to content

Commit b9ebb20

Browse files
laurmaedjereknih
andcommitted
Association kinds for embedded files
Co-Authored-By: Martin Haug <[email protected]>
1 parent cba8c6f commit b9ebb20

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

src/files.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ impl<'a> FileSpec<'a> {
6262
self.insert(Name(b"EF")).dict().pair(Name(b"F"), id);
6363
self
6464
}
65+
66+
/// How this file relates to the PDF document it is embedded in.
67+
/// PDF/A-3 and PDF/A-4f.
68+
pub fn association_kind(&mut self, kind: AssociationKind) -> &mut Self {
69+
self.pair(Name(b"AFRelationship"), kind.to_name());
70+
self
71+
}
6572
}
6673

6774
deref!('a, FileSpec<'a> => Dict<'a>, dict);
@@ -137,3 +144,31 @@ impl<'a> EmbeddingParams<'a> {
137144
}
138145

139146
deref!('a, EmbeddingParams<'a> => Dict<'a>, dict);
147+
148+
/// How an embedded file relates to the PDF document it is embedded in.
149+
/// PDF/A-3 and PDF/A-4f.
150+
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
151+
pub enum AssociationKind {
152+
/// The PDF document was created from this source file.
153+
Source,
154+
/// This file was used to derive a visual presentation in the PDF.
155+
Data,
156+
/// An alternative representation of this document.
157+
Alternative,
158+
/// Additional resources for this document.
159+
Supplement,
160+
/// There is no clear relationship or it is not known.
161+
Unspecified,
162+
}
163+
164+
impl AssociationKind {
165+
pub(crate) fn to_name(self) -> Name<'static> {
166+
match self {
167+
Self::Source => Name(b"Source"),
168+
Self::Data => Name(b"Data"),
169+
Self::Alternative => Name(b"Alternative"),
170+
Self::Supplement => Name(b"Supplement"),
171+
Self::Unspecified => Name(b"Unspecified"),
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)