diff --git a/src/annotations.rs b/src/annotations.rs index f66c035..ea08fa0 100644 --- a/src/annotations.rs +++ b/src/annotations.rs @@ -228,6 +228,12 @@ impl<'a> Annotation<'a> { self.pair(Name(b"Parent"), id); self } + + /// Start writing the `/AF` array to specify the associated files of the + /// annotation. PDF 2.0+ or PDF/A-3. + pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { + self.insert(Name(b"AF")).array().typed() + } } deref!('a, Annotation<'a> => Dict<'a>, dict); diff --git a/src/files.rs b/src/files.rs index b32ed7d..40b0842 100644 --- a/src/files.rs +++ b/src/files.rs @@ -53,8 +53,9 @@ impl<'a> FileSpec<'a> { /// PDF 1.3+. /// /// This only sets an embedded file for the `F` attribute corresponding to - /// the [`path`](Self::path) method. You will need to write this dictionary - /// manually if you need to set `UF` which is required in PDF/A-3. + /// the [`path`](Self::path) method. If you want to set the same embedded + /// file for the `UF` attribute, also call [`Self::embedded_file_with_unicode`] + /// instead. /// /// Note that this key is forbidden in PDF/A-1 and restricted in PDF/A-2 and /// PDF/A-4. @@ -63,6 +64,19 @@ impl<'a> FileSpec<'a> { self } + /// Write the `/EF` attribute to reference an [embedded file](EmbeddedFile) + /// for the legacy and Unicode-compatible file path. PDF 1.7+. + /// + /// Note that this key is forbidden in PDF/A-1 and restricted in PDF/A-2 an + /// PDF/A-4. + pub fn embedded_file_with_unicode(&mut self, id: Ref) -> &mut Self { + self.insert(Name(b"EF")) + .dict() + .pair(Name(b"F"), id) + .pair(Name(b"UF"), id); + self + } + /// How this file relates to the PDF document it is embedded in. /// PDF/A-3 and PDF/A-4f. pub fn association_kind(&mut self, kind: AssociationKind) -> &mut Self { diff --git a/src/structure.rs b/src/structure.rs index c5ab56a..bcf939a 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -147,7 +147,7 @@ impl<'a> Catalog<'a> { } /// Start writing the `/AF` array to specify the associated files of the - /// document. PDF 2.0+. + /// document. PDF 2.0+ or PDF/A-3. pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { self.insert(Name(b"AF")).array().typed() } @@ -495,6 +495,12 @@ impl<'a> StructElement<'a> { self.dict.pair(Name(b"ActualText"), actual_text); self } + + /// Start writing the `/AF` array to specify the associated files of the + /// element. PDF 2.0+ or PDF/A-3. + pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { + self.insert(Name(b"AF")).array().typed() + } } deref!('a, StructElement<'a> => Dict<'a>, dict); @@ -1247,6 +1253,12 @@ impl<'a> Page<'a> { self.pair(Name(b"Metadata"), id); self } + + /// Start writing the `/AF` array to specify the associated files of the + /// page. PDF 2.0+ or PDF/A-3. + pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { + self.insert(Name(b"AF")).array().typed() + } } deref!('a, Page<'a> => Dict<'a>, dict); diff --git a/src/xobject.rs b/src/xobject.rs index 8ccc72e..18bf7b3 100644 --- a/src/xobject.rs +++ b/src/xobject.rs @@ -155,6 +155,12 @@ impl<'a> ImageXObject<'a> { self.pair(Name(b"Metadata"), id); self } + + /// Start writing the `/AF` array to specify the associated files of the + /// image. PDF 2.0+ or PDF/A-3. + pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { + self.insert(Name(b"AF")).array().typed() + } } deref!('a, ImageXObject<'a> => Stream<'a>, stream); @@ -263,6 +269,12 @@ impl<'a> FormXObject<'a> { self.pair(Name(b"LastModified"), last_modified); self } + + /// Start writing the `/AF` array to specify the associated files of the + /// Form XObject. PDF 2.0+ or PDF/A-3. + pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec> { + self.insert(Name(b"AF")).array().typed() + } } deref!('a, FormXObject<'a> => Stream<'a>, stream);