Skip to content

Commit

Permalink
appearance streams..
Browse files Browse the repository at this point in the history
  • Loading branch information
s3bk committed Dec 2, 2023
1 parent e66c79b commit 3eb1258
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pdf/src/object/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ impl RenderingIntent {
}


#[derive(Object, Debug, DataSize, DeepClone, ObjectWrite)]
#[derive(Object, Debug, DataSize, DeepClone, ObjectWrite, Clone, Default)]
#[pdf(Type="XObject?", Subtype="Form")]
pub struct FormDict {
#[pdf(key="FormType", default="1")]
Expand Down Expand Up @@ -962,30 +962,33 @@ pub struct FieldDictionary {
#[pdf(key="AP")]
pub appearance_streams: Option<MaybeRef<AppearanceStreams>>,

#[pdf(key="Rect")]
pub rect: Rect,

#[pdf(other)]
pub other: Dictionary
}

#[derive(Object, ObjectWrite, Debug, DataSize, Clone)]
#[derive(Object, ObjectWrite, Debug, DataSize, Clone, DeepClone)]
pub struct AppearanceStreams {
#[pdf(key="N")]
pub normal: AppearanceStreamEntry,
pub normal: Ref<AppearanceStreamEntry>,

#[pdf(key="R")]
pub rollover: Option<AppearanceStreamEntry>,
pub rollover: Option<Ref<AppearanceStreamEntry>>,

#[pdf(key="D")]
pub down: Option<AppearanceStreamEntry>,
pub down: Option<Ref<AppearanceStreamEntry>>,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, DeepClone)]
pub enum AppearanceStreamEntry {
Single(Stream<Dictionary>),
Single(FormXObject),
Dict(HashMap<Name, AppearanceStreamEntry>)
}
impl Object for AppearanceStreamEntry {
fn from_primitive(p: Primitive, resolve: &impl Resolve) -> Result<Self> {
match dbg!(p.resolve(resolve)?) {
match p.resolve(resolve)? {
p @ Primitive::Dictionary(_) => Object::from_primitive(p, resolve).map(AppearanceStreamEntry::Dict),
p @ Primitive::Stream(_) => Object::from_primitive(p, resolve).map(AppearanceStreamEntry::Single),
p => Err(PdfError::UnexpectedPrimitive {expected: "Dict or Stream", found: p.get_debug_name()})
Expand Down Expand Up @@ -1471,7 +1474,7 @@ pub struct Outlines {

}

#[derive(Debug, Copy, Clone, DataSize)]
#[derive(Debug, Copy, Clone, DataSize, Default)]
pub struct Rect {
pub left: f32,
pub bottom: f32,
Expand Down

0 comments on commit 3eb1258

Please sign in to comment.