#[cfg(feature = "write")]
use lopdf::Object;
#[cfg(feature = "write")]
#[derive(Debug, Clone, Copy)]
pub struct AnnotRect {
pub x0: f64,
pub y0: f64,
pub x1: f64,
pub y1: f64,
}
#[cfg(feature = "write")]
impl AnnotRect {
pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Self {
Self { x0, y0, x1, y1 }
}
pub fn width(&self) -> f64 {
(self.x1 - self.x0).abs()
}
pub fn height(&self) -> f64 {
(self.y1 - self.y0).abs()
}
pub(super) fn as_array(&self) -> Object {
Object::Array(vec![
Object::Real(self.x0 as f32),
Object::Real(self.y0 as f32),
Object::Real(self.x1 as f32),
Object::Real(self.y1 as f32),
])
}
}
#[cfg(feature = "write")]
#[derive(Debug, Clone, Copy)]
pub enum AnnotSubtype {
Square,
Circle,
Line,
Highlight,
Underline,
StrikeOut,
Squiggly,
FreeText,
Text,
Stamp,
Ink,
Polygon,
PolyLine,
Link,
}
#[cfg(feature = "write")]
impl AnnotSubtype {
pub(super) fn as_str(&self) -> &'static str {
match self {
Self::Square => "Square",
Self::Circle => "Circle",
Self::Line => "Line",
Self::Highlight => "Highlight",
Self::Underline => "Underline",
Self::StrikeOut => "StrikeOut",
Self::Squiggly => "Squiggly",
Self::FreeText => "FreeText",
Self::Text => "Text",
Self::Stamp => "Stamp",
Self::Ink => "Ink",
Self::Polygon => "Polygon",
Self::PolyLine => "PolyLine",
Self::Link => "Link",
}
}
}
#[cfg(feature = "write")]
#[derive(Debug, Clone, Copy)]
pub enum TextIcon {
Comment,
Key,
Note,
Help,
NewParagraph,
Paragraph,
Insert,
}
#[cfg(feature = "write")]
impl TextIcon {
pub(super) fn as_str(&self) -> &'static str {
match self {
Self::Comment => "Comment",
Self::Key => "Key",
Self::Note => "Note",
Self::Help => "Help",
Self::NewParagraph => "NewParagraph",
Self::Paragraph => "Paragraph",
Self::Insert => "Insert",
}
}
}
#[cfg(feature = "write")]
#[derive(Debug, Clone, Copy)]
pub enum LineEnding {
None,
Square,
Circle,
Diamond,
OpenArrow,
ClosedArrow,
Butt,
ROpenArrow,
RClosedArrow,
Slash,
}
#[cfg(feature = "write")]
impl LineEnding {
pub(super) fn as_str(&self) -> &'static str {
match self {
Self::None => "None",
Self::Square => "Square",
Self::Circle => "Circle",
Self::Diamond => "Diamond",
Self::OpenArrow => "OpenArrow",
Self::ClosedArrow => "ClosedArrow",
Self::Butt => "Butt",
Self::ROpenArrow => "ROpenArrow",
Self::RClosedArrow => "RClosedArrow",
Self::Slash => "Slash",
}
}
}