diff --git a/src/functions.rs b/src/functions.rs index 2a15bb4..9cbe3fd 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -237,7 +237,7 @@ impl<'a> PostScriptFunction<'a> { deref!('a, PostScriptFunction<'a> => Stream<'a>, stream); /// PostScript operators for use in Type 4 functions. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq)] pub enum PostScriptOp<'a> { /// Push a real number. Real(f32), @@ -333,7 +333,7 @@ pub enum PostScriptOp<'a> { Roll, } -impl PostScriptOp<'_> { +impl<'a> PostScriptOp<'a> { /// Encode a slice of operations into a byte stream. pub fn encode(ops: &[Self]) -> Buf { let mut buf = Buf::new(); @@ -446,8 +446,8 @@ mod tests { ]; assert_eq!( - PostScriptOp::encode(&ops).to_bytes(), - b"{\n3.0\n2.0\nmul\nexch\ndup\n0.0\nge\n{\n1.0\nadd\n}\n{neg}\nifelse\nadd\n}" + PostScriptOp::encode(&ops), + b"{ 3.0 2.0 mul exch dup 0.0 ge { 1.0 add } {neg} ifelse add }" ); } } diff --git a/src/structure.rs b/src/structure.rs index bcf939a..4f9ab5c 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -290,6 +290,14 @@ impl<'a> ViewerPreferences<'a> { self } + /// Write the `/DisplayDocTitle` attribute to set whether the viewer should + /// display the document's title from the `Title` entry as the window's title. + /// PDF 1.4+ + pub fn display_doc_title(&mut self, display: bool) -> &mut Self { + self.pair(Name(b"DisplayDocTitle"), display); + self + } + /// Write the `/NonFullScreenPageMode` attribute to set which chrome /// elements the viewer should show for a document which requests full /// screen rendering in its catalog when it is not shown in full screen @@ -413,6 +421,13 @@ impl<'a> StructElement<'a> { self } + /// Write the `/ID` attribute to specify the element identifier of this + /// structure element. + pub fn id(&mut self, id: Str) -> &mut Self { + self.dict.pair(Name(b"ID"), id); + self + } + /// Write the `/Pg` attribute to specify the page some or all of this /// structure element is located on. pub fn page(&mut self, page: Ref) -> &mut Self {