Skip to content

Commit 2247601

Browse files
committed
Add NamespaceRoleMap::to_pdf_2_0
1 parent 1e47f9a commit 2247601

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/structure.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,25 @@ impl NamespaceRoleMap<'_> {
15861586
dict.finish();
15871587
self
15881588
}
1589+
1590+
/// Write an entry mapping a custom structure type to an element in the
1591+
/// PDF 2.0 namespace.
1592+
///
1593+
/// The `pdf_2_ns` parameter is an indirect reference to a PDF 2.0 namespace
1594+
/// dictionary. You can create this dictionary by using [`Chunk::namespace`]
1595+
/// and then calling [`Namespace::pdf_2_ns`] on the returned writer.
1596+
pub fn to_pdf_2_0(
1597+
&mut self,
1598+
name: Name,
1599+
role: StructRole2,
1600+
pdf_2_ns: Ref,
1601+
) -> &mut Self {
1602+
let mut dict = self.dict.insert(name).dict();
1603+
dict.pair(Name(b"Role"), Name(role.to_name_bytes(&mut [0; 6])));
1604+
dict.pair(Name(b"NS"), pdf_2_ns);
1605+
dict.finish();
1606+
self
1607+
}
15891608
}
15901609

15911610
deref!('a, NamespaceRoleMap<'a> => Dict<'a>, dict);

0 commit comments

Comments
 (0)