pdf_writer::writers

Struct Annotation

source
pub struct Annotation<'a> { /* private fields */ }
Expand description

Writer for an annotation dictionary.

An array of this struct is created by Chunk::annotation.

Implementations§

source§

impl<'a> Annotation<'a>

source

pub fn subtype(&mut self, kind: AnnotationType) -> &mut Self

Write the /Subtype attribute to tell the viewer the type of this particular annotation.

source

pub fn rect(&mut self, rect: Rect) -> &mut Self

Write the /Rect attribute. This is the location and dimensions of the annotation on the page.

source

pub fn contents(&mut self, text: TextStr<'_>) -> &mut Self

Write the /Contents attribute. This is the content or alt-text, depending on the AnnotationType.

source

pub fn page(&mut self, id: Ref) -> &mut Self

Write the /P attribute. This provides an indirect reference to the page object with which this annotation is associated. Required for the subtype Screen associated with rendition actions. PDF 1.3+.

source

pub fn name(&mut self, text: TextStr<'_>) -> &mut Self

Write the /NM attribute. This uniquely identifies the annotation on the page. PDF 1.3+.

source

pub fn modified(&mut self, date: Date) -> &mut Self

Write the /M attribute, specifying the date the annotation was last modified. PDF 1.1+.

source

pub fn flags(&mut self, flags: AnnotationFlags) -> &mut Self

Write the /F attribute.

Required for all annotations in PDF/A except for Popup.

source

pub fn appearance(&mut self) -> Appearance<'_>

Start writing the /AP dictionary to set how the annotation shall be presented visually. If this dictionary contains sub dictionaries, Self::appearance_state must be set. PDF 1.2+.

Required for many annotations in PDF/A.

source

pub fn appearance_state(&mut self, name: Name<'_>) -> &mut Self

Write the /AS attribute to set the annotation’s current appearance state from the /AP subdictionary. Must be set if Self::appearance has one or more subdictionaries. PDF 1.2+.

source

pub fn border( &mut self, h_radius: f32, v_radius: f32, width: f32, dash_pattern: Option<&[f32]>, ) -> &mut Self

Write the /Border attribute. This describes the look of the border around the annotation, including width and horizontal and vertical border radii. The function may also receive a dash pattern which specifies the lengths and gaps of the border segments on a dashed border. Although all PDF versions accept /Border, this feature specifically is only available in PDF 1.1 or later.

source

pub fn border_style(&mut self) -> BorderStyle<'_>

Start writing the /BS attribute. These are some more elaborate border settings taking precedence over /B for some annotation types. PDF 1.2+.

source

pub fn color_transparent(&mut self) -> &mut Self

Write the /C attribute forcing a transparent color. This sets the annotations background color and its popup title bar color. PDF 1.1+.

source

pub fn color_gray(&mut self, gray: f32) -> &mut Self

Write the /C attribute using a grayscale color. This sets the annotations background color and its popup title bar color. PDF 1.1+.

source

pub fn color_rgb(&mut self, r: f32, g: f32, b: f32) -> &mut Self

Write the /C attribute using an RGB color. This sets the annotations background color and its popup title bar color. PDF 1.1+.

source

pub fn color_cmyk(&mut self, c: f32, m: f32, y: f32, k: f32) -> &mut Self

Write the /C attribute using a CMYK color. This sets the annotations background color and its popup title bar color. PDF 1.1+.

source

pub fn struct_parent(&mut self, key: i32) -> &mut Self

Write the /StructParent attribute to indicate the structure tree element this annotation belongs to. PDF 1.3+.

source

pub fn action(&mut self) -> Action<'_>

Start writing the /A dictionary. Only permissible for the subtypes Link and Widget.

Note that this attribute is forbidden in PDF/A.

source

pub fn additional_actions(&mut self) -> AdditionalActions<'_>

Start writing the /AA dictionary. Only permissible for the subtype Widget. PDF 1.3+.

Note that this attribute is forbidden in PDF/A.

source

pub fn highlight(&mut self, effect: HighlightEffect) -> &mut Self

Write the /H attribute to set what effect is used to convey that the user is pressing a link or widget annotation. Only permissible for the subtypes Link and Widget. PDF 1.2+.

source

pub fn author(&mut self, text: TextStr<'_>) -> &mut Self

Write the /T attribute. This is in the title bar of markup annotations and should be the name of the annotation author. PDF 1.1+.

source

pub fn subject(&mut self, text: TextStr<'_>) -> &mut Self

Write the /Subj attribute. This is the subject of the annotation. PDF 1.5+.

source

pub fn quad_points( &mut self, coordinates: impl IntoIterator<Item = f32>, ) -> &mut Self

Write the /QuadPoints attribute, specifying the region in which the link should be activated. PDF 1.6+.

source

pub fn line_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> &mut Self

Write the /L attribute. This defines the start and end point of a line annotation

source

pub fn file_spec(&mut self) -> FileSpec<'_>

Start writing the /FS attribute, setting which file to reference.

source

pub fn icon(&mut self, icon: AnnotationIcon<'_>) -> &mut Self

Write the /Name attribute. Refer to the specification to see which names are allowed for which annotation types.

source

pub fn appearance_characteristics(&mut self) -> AppearanceCharacteristics<'_>

Start writing the /MK dictionary. Only permissible for the subtype Widget.

source

pub fn parent(&mut self, id: Ref) -> &mut Self

Write the /Parent attribute. Only permissible for the subtype Widget.

source

pub fn associated_files(&mut self) -> TypedArray<'_, FileSpec<'_>>

Start writing the /AF array to specify the associated files of the annotation. PDF 2.0+ or PDF/A-3.

Methods from Deref<Target = Dict<'a>>§

source

pub fn len(&self) -> i32

The number of written pairs.

source

pub fn is_empty(&self) -> bool

Whether no pairs have been written so far.

source

pub fn insert(&mut self, key: Name<'_>) -> Obj<'_>

Start writing a pair with an arbitrary value.

source

pub fn pair<T: Primitive>(&mut self, key: Name<'_>, value: T) -> &mut Self

Write a pair with a primitive value.

This is a shorthand for dict.insert(key).primitive(value).

source

pub fn pairs<'n, T: Primitive>( &mut self, pairs: impl IntoIterator<Item = (Name<'n>, T)>, ) -> &mut Self

Write a sequence of pairs with primitive values.

Trait Implementations§

source§

impl<'a> Deref for Annotation<'a>

source§

type Target = Dict<'a>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a> DerefMut for Annotation<'a>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, 'any> Rewrite<'a> for Annotation<'any>

source§

type Output = Annotation<'a>

The writer with the rewritten lifetime.
source§

impl<'a> Writer<'a> for Annotation<'a>

source§

fn start(obj: Obj<'a>) -> Self

Start writing the object.

Auto Trait Implementations§

§

impl<'a> Freeze for Annotation<'a>

§

impl<'a> RefUnwindSafe for Annotation<'a>

§

impl<'a> Send for Annotation<'a>

§

impl<'a> Sync for Annotation<'a>

§

impl<'a> Unpin for Annotation<'a>

§

impl<'a> !UnwindSafe for Annotation<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Finish for T

source§

fn finish(self)

Does nothing but move self, equivalent to drop.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.