Skip to content

Commit

Permalink
Export form field types
Browse files Browse the repository at this point in the history
  • Loading branch information
reknih committed Oct 22, 2023
1 parent bb19bfd commit a3c1647
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ bitflags::bitflags! {

/// Writer for an _appearance characteristics dictionary_.
///
/// This struct is created by [`Annotation::appearance`].
/// This struct is created by [`Annotation::appearance_characteristics`].
pub struct AppearanceCharacteristics<'a> {
dict: Dict<'a>,
}
Expand Down Expand Up @@ -486,7 +486,7 @@ pub enum TextPosition {

/// Writer for an _icon fit dictionary_.
///
/// This struct is created by [`Appearance::icon_fit`].
/// This struct is created by [`AppearanceCharacteristics::icon_fit`].
pub struct IconFit<'a> {
dict: Dict<'a>,
}
Expand Down
8 changes: 8 additions & 0 deletions src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ impl Chunk {
}
}

/// Interactive features.
impl Chunk {
/// Start writing a form field dictionary.
pub fn form_field(&mut self, id: Ref) -> Field<'_> {
self.indirect(id).start()
}
}

impl Debug for Chunk {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.pad("Chunk(..)")
Expand Down
26 changes: 15 additions & 11 deletions src/forms.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::*;

/// A form field.
///
/// This struct is created by [`Chunk::form_field`].
pub struct Field<'a> {
dict: Dict<'a>,
}
Expand Down Expand Up @@ -117,18 +119,18 @@ impl<'a> Field<'a> {

/// Only permissible on check box fields.
impl<'a> Field<'a> {
/// Write the `/V` attribute to set the state of this check box field.
/// The state corresponds to an appearance stream in the
/// [appearance dictionary](Appearance) of this field's widget
/// Write the `/V` attribute to set the state of this check box field. The
/// state corresponds to an appearance stream in the [appearance
/// dictionary](AppearanceCharacteristics) of this field's widget
/// [annotation](Annotation). Only permissible on check box fields.
pub fn checkbox_value(&mut self, state: CheckBoxState) -> &mut Self {
self.dict.pair(Name(b"V"), state.to_name());
self
}

/// Write the `/DV` attribute to set the default state of this check box
/// field. The state corresponds to an appearance stream in the
/// [appearance dictionary](Appearance) of this field's widget
/// field. The state corresponds to an appearance stream in the [appearance
/// dictionary](AppearanceCharacteristics) of this field's widget
/// [annotation](Annotation). Only permissible on check box fields.
pub fn checkbox_default_value(&mut self, state: CheckBoxState) -> &mut Self {
self.dict.pair(Name(b"DV"), state.to_name());
Expand All @@ -155,19 +157,21 @@ impl CheckBoxState {

/// Only permissible on radio button fields.
impl<'a> Field<'a> {
/// Write the `/V` attribute to set the state of this check box field.
/// The state corresponds to an appearance stream in the
/// [appearance dictionary](Appearance) of this field's widget
/// [annotation](Annotation). Only permissible on radio button fields.
/// Write the `/V` attribute to set the state of this check box field. The
/// state corresponds to an appearance stream in the
/// [appearance dictionary](AppearanceCharacteristics) of this field's
/// widget [annotation](Annotation). Only permissible on radio button
/// fields.
pub fn radio_value(&mut self, state: RadioState) -> &mut Self {
self.dict.pair(Name(b"V"), state.to_name());
self
}

/// Write the `/DV` attribute to set the default state of this check box
/// field. The state corresponds to an appearance stream in the
/// [appearance dictionary](Appearance) of this field's widget
/// [annotation](Annotation). Only permissible on radio button fields.
/// [appearance dictionary](AppearanceCharacteristics) of this field's
/// widget [annotation](Annotation). Only permissible on radio button
/// fields.
pub fn radio_default_value(&mut self, state: RadioState) -> &mut Self {
self.dict.pair(Name(b"DV"), state.to_name());
self
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ pub mod types {
TextRenderingMode,
};
pub use font::{CidFontType, FontFlags, FontStretch, SystemInfo, UnicodeCmap};
pub use forms::{FieldFlags, FieldType};
pub use forms::{
CheckBoxState, ChoiceOptions, FieldFlags, FieldType, Quadding, RadioState,
};
pub use functions::{InterpolationOrder, PostScriptOp};
pub use structure::{
Direction, NumberingStyle, OutlineItemFlags, PageLayout, PageMode, StructRole,
Expand Down

0 comments on commit a3c1647

Please sign in to comment.