Skip to content

Commit

Permalink
Merge branch 'main' into buf-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/functions.rs
  • Loading branch information
LaurenzV committed Oct 30, 2024
2 parents cf042eb + 22e39a3 commit ccb54f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 }"
);
}
}
15 changes: 15 additions & 0 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ccb54f4

Please sign in to comment.