### start_tagged Source: https://docs.rs/krilla/latest/src/krilla/surface.rs.html Starts a new tagged content section. Panics if a tagged section has already been started or if an artifact with a required bbox has none. ```APIDOC ## start_tagged ### Description Starts a new tagged content section. Panics if a tagged section has already been started or if an artifact with a required bbox has none. ### Method start_tagged ### Parameters - **tag** (ContentTag) - Required - The content tag for the section. ### Returns - **Identifier** - The identifier for the tagged section. ### Panics - Panics if a tagged section has already been started. - Panics if an artifact with a required bbox has none. ### Example ```rust let id = surface.start_tagged(tag); ``` ``` -------------------------------- ### Document::start_page Source: https://docs.rs/krilla/latest/krilla/document/struct.Document.html Starts a new page with default settings. ```APIDOC ## Document::start_page ### Description Starts a new page in the document with default page settings. ### Method start_page ### Signature pub fn start_page(&mut self) -> Page<'_> ### Parameters None ### Returns Page<'_> - A Page object for the new page. ``` -------------------------------- ### Surface::start_tagged Source: https://docs.rs/krilla/latest/krilla/surface/struct.Surface.html Starts a new tagged content section. ```APIDOC ## Surface::start_tagged ### Description Starts a new tagged content section. ### Method start_tagged ### Signature pub fn start_tagged(&mut self, tag: ContentTag<'_>) -> Identifier ### Parameters - **tag** (ContentTag<'_>) - Required - The content tag for the section. ### Returns - **Identifier** - An identifier for the tagged section. ### Panics Panics if a tagged section has already been started. Panics if an artifact with a required bbox has none. ``` -------------------------------- ### Document::start_page_with Source: https://docs.rs/krilla/latest/krilla/document/struct.Document.html Starts a new page with specific page settings. ```APIDOC ## Document::start_page_with ### Description Starts a new page in the document with custom page settings. ### Method start_page_with ### Signature pub fn start_page_with(&mut self, page_settings: PageSettings) -> Page<'_> ### Parameters - **page_settings** (PageSettings) - Required - The settings for the new page. ### Returns Page<'_> - A Page object for the new page. ``` -------------------------------- ### PathBuilder::new Source: https://docs.rs/krilla/latest/krilla/geom/struct.PathBuilder.html Creates a new PathBuilder instance to start building a path. ```APIDOC ## PathBuilder::new ### Description Creates a new path builder. ### Signature pub fn new() -> Self ### Parameters None ### Returns - **Self** - A new PathBuilder instance. ``` -------------------------------- ### Tag::with_start_indent Source: https://docs.rs/krilla/latest/krilla/tagging/struct.Tag.html Sets the start indent and returns the modified tag. ```APIDOC ## Tag::with_start_indent ### Description Sets the start indent and returns the modified tag. ### Method Fluent setter ### Signature pub fn with_start_indent(self, start_indent: Option) -> Self ### Parameters - **start_indent** (Option) - Required - The new spacing between the start inline edge of the element and the parent. ### Returns - **Self** - The modified Tag. ``` -------------------------------- ### Create a Tag with attributes and add to TagTree Source: https://docs.rs/krilla/latest/krilla/tagging/struct.Tag.html Example from the documentation showing how to construct a Tag::TH with id, column span, headers, width, and height, then wrap it in a TagGroup and push it into a TagTree. ```rust use std::num::NonZeroU32; use krilla::tagging::{TagGroup, TagTree, TableHeaderScope, Tag, TagId}; let tag = Tag::TH(TableHeaderScope::Row) .with_id(Some(TagId::from(*b"this id"))) .with_col_span(Some(NonZeroU32::new(3).unwrap())) .with_headers(Some([TagId::from(*b"parent id")])) .with_width(Some(250.0)) .with_height(Some(100.0)); let group = TagGroup::new(tag); let mut tree = TagTree::new(); tree.push(group); ``` -------------------------------- ### Layout Attribute Methods Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Methods to get, set, and build layout attributes for line height, text decoration, and glyph orientation. ```APIDOC ## Layout Attribute Methods ### Description These methods allow getting, setting, and building layout attributes on an element, including line height, text decoration color, thickness, type, and glyph orientation in vertical writing modes. ### Methods #### line_height() - **Signature**: `pub fn line_height(&self) -> Option` - **Description**: Get the height of each line in an element on the block axis. #### set_line_height(line_height: Option) - **Signature**: `pub fn set_line_height(&mut self, line_height: Option)` - **Description**: Set the height of each line in an element on the block axis. #### with_line_height(line_height: Option) -> Self - **Signature**: `pub fn with_line_height(mut self, line_height: Option) -> Self` - **Description**: Set the height of each line in an element on the block axis and return the element for chaining. #### text_decoration_color() - **Signature**: `pub fn text_decoration_color(&self) -> Option` - **Description**: Get the color of the text decoration, overriding the fill color. #### set_text_decoration_color(text_decoration_color: Option) - **Signature**: `pub fn set_text_decoration_color(&mut self, text_decoration_color: Option)` - **Description**: Set the color of the text decoration, overriding the fill color. #### with_text_decoration_color(text_decoration_color: Option) -> Self - **Signature**: `pub fn with_text_decoration_color(mut self, text_decoration_color: Option) -> Self` - **Description**: Set the color of the text decoration, overriding the fill color, and return the element for chaining. #### text_decoration_thickness() - **Signature**: `pub fn text_decoration_thickness(&self) -> Option` - **Description**: Get the width of the text decoration line. #### set_text_decoration_thickness(text_decoration_thickness: Option) - **Signature**: `pub fn set_text_decoration_thickness(&mut self, text_decoration_thickness: Option)` - **Description**: Set the width of the text decoration line. #### with_text_decoration_thickness(text_decoration_thickness: Option) -> Self - **Signature**: `pub fn with_text_decoration_thickness(mut self, text_decoration_thickness: Option) -> Self` - **Description**: Set the width of the text decoration line and return the element for chaining. #### text_decoration_type() - **Signature**: `pub fn text_decoration_type(&self) -> Option` - **Description**: Get the kind of text decoration. #### set_text_decoration_type(text_decoration_type: Option) - **Signature**: `pub fn set_text_decoration_type(&mut self, text_decoration_type: Option)` - **Description**: Set the kind of text decoration. #### with_text_decoration_type(text_decoration_type: Option) -> Self - **Signature**: `pub fn with_text_decoration_type(mut self, text_decoration_type: Option) -> Self` - **Description**: Set the kind of text decoration and return the element for chaining. #### glyph_orientation_vertical() - **Signature**: `pub fn glyph_orientation_vertical(&self) -> Option` - **Description**: Get how the glyphs are rotated in a vertical writing mode. #### set_glyph_orientation_vertical(glyph_orientation_vertical: Option) - **Signature**: `pub fn set_glyph_orientation_vertical(&mut self, glyph_orientation_vertical: Option)` - **Description**: Set how the glyphs are rotated in a vertical writing mode. #### with_glyph_orientation_vertical(glyph_orientation_vertical: Option) -> Self - **Signature**: `pub fn with_glyph_orientation_vertical(mut self, glyph_orientation_vertical: Option) -> Self` - **Description**: Set how the glyphs are rotated in a vertical writing mode and return the element for chaining. ### Parameters All methods accept the corresponding attribute value wrapped in `Option`. The `with_*` methods consume and return the element for chaining. ### Return Values - Getter methods return `Option`, `Option`, `Option`, `Option`, or `Option`. - Setter methods return `()`. - Builder methods return `Self`. ``` -------------------------------- ### Tag layout methods Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Methods to get and set layout properties (space before/after, start/end indent) on a Tag of kind Link. ```APIDOC ## Tag layout methods ### Description Methods to get and set layout properties (space before/after, start/end indent) on a Tag of kind Link. ### Methods #### space_before - **Signature**: `pub fn space_before(&self) -> Option` - **Description**: Returns the spacing before the block-level element. #### set_space_before - **Signature**: `pub fn set_space_before(&mut self, space_before: Option)` - **Description**: Sets the spacing before the block-level element. - **Parameters**: - `space_before` (Option) - The spacing value to set. #### with_space_before - **Signature**: `pub fn with_space_before(mut self, space_before: Option) -> Self` - **Description**: Sets the spacing before the block-level element and returns the modified Tag. - **Parameters**: - `space_before` (Option) - The spacing value to set. #### space_after - **Signature**: `pub fn space_after(&self) -> Option` - **Description**: Returns the spacing after the block-level element. #### set_space_after - **Signature**: `pub fn set_space_after(&mut self, space_after: Option)` - **Description**: Sets the spacing after the block-level element. - **Parameters**: - `space_after` (Option) - The spacing value to set. #### with_space_after - **Signature**: `pub fn with_space_after(mut self, space_after: Option) -> Self` - **Description**: Sets the spacing after the block-level element and returns the modified Tag. - **Parameters**: - `space_after` (Option) - The spacing value to set. #### start_indent - **Signature**: `pub fn start_indent(&self) -> Option` - **Description**: Returns the spacing between the start inline edge of the element and the parent. #### set_start_indent - **Signature**: `pub fn set_start_indent(&mut self, start_indent: Option)` - **Description**: Sets the spacing between the start inline edge of the element and the parent. - **Parameters**: - `start_indent` (Option) - The spacing value to set. #### with_start_indent - **Signature**: `pub fn with_start_indent(mut self, start_indent: Option) -> Self` - **Description**: Sets the spacing between the start inline edge of the element and the parent and returns the modified Tag. - **Parameters**: - `start_indent` (Option) - The spacing value to set. #### end_indent - **Signature**: `pub fn end_indent(&self) -> Option` - **Description**: Returns the spacing between the end inline edge of the element and the parent. #### set_end_indent - **Signature**: `pub fn set_end_indent(&mut self, end_indent: Option)` - **Description**: Sets the spacing between the end inline edge of the element and the parent. - **Parameters**: - `end_indent` (Option) - The spacing value to set. #### with_end_indent - **Signature**: `pub fn with_end_indent(mut self, end_indent: Option) -> Self` - **Description**: Sets the spacing between the end inline edge of the element and the parent and returns the modified Tag. - **Parameters**: - `end_indent` (Option) - The spacing value to set. ``` -------------------------------- ### Tag Layout Methods Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Methods to get and set layout attributes on a Tag instance, including space before/after, indents, and text alignment. ```APIDOC ## Tag Layout Methods ### Description Provides getter, setter, and builder-style methods for managing layout attributes on a Tag instance. ### Methods #### space_before() - **Signature**: `pub fn space_before(&self) -> Option` - **Description**: Returns the spacing before the block-level element. #### set_space_before(space_before: Option) - **Signature**: `pub fn set_space_before(&mut self, space_before: Option)` - **Description**: Sets the spacing before the block-level element. - **Parameters**: - `space_before` (Option) - The spacing value to set. #### with_space_before(space_before: Option) -> Self - **Signature**: `pub fn with_space_before(mut self, space_before: Option) -> Self` - **Description**: Sets the spacing before the block-level element and returns the modified instance. - **Parameters**: - `space_before` (Option) - The spacing value to set. #### space_after() - **Signature**: `pub fn space_after(&self) -> Option` - **Description**: Returns the spacing after the block-level element. #### set_space_after(space_after: Option) - **Signature**: `pub fn set_space_after(&mut self, space_after: Option)` - **Description**: Sets the spacing after the block-level element. - **Parameters**: - `space_after` (Option) - The spacing value to set. #### with_space_after(space_after: Option) -> Self - **Signature**: `pub fn with_space_after(mut self, space_after: Option) -> Self` - **Description**: Sets the spacing after the block-level element and returns the modified instance. - **Parameters**: - `space_after` (Option) - The spacing value to set. #### start_indent() - **Signature**: `pub fn start_indent(&self) -> Option` - **Description**: Returns the spacing between the start inline edge of the element and the parent. #### set_start_indent(start_indent: Option) - **Signature**: `pub fn set_start_indent(&mut self, start_indent: Option)` - **Description**: Sets the spacing between the start inline edge of the element and the parent. - **Parameters**: - `start_indent` (Option) - The indent value to set. #### with_start_indent(start_indent: Option) -> Self - **Signature**: `pub fn with_start_indent(mut self, start_indent: Option) -> Self` - **Description**: Sets the spacing between the start inline edge of the element and the parent and returns the modified instance. - **Parameters**: - `start_indent` (Option) - The indent value to set. #### end_indent() - **Signature**: `pub fn end_indent(&self) -> Option` - **Description**: Returns the spacing between the end inline edge of the element and the parent. #### set_end_indent(end_indent: Option) - **Signature**: `pub fn set_end_indent(&mut self, end_indent: Option)` - **Description**: Sets the spacing between the end inline edge of the element and the parent. - **Parameters**: - `end_indent` (Option) - The indent value to set. #### with_end_indent(end_indent: Option) -> Self - **Signature**: `pub fn with_end_indent(mut self, end_indent: Option) -> Self` - **Description**: Sets the spacing between the end inline edge of the element and the parent and returns the modified instance. - **Parameters**: - `end_indent` (Option) - The indent value to set. #### text_indent() - **Signature**: `pub fn text_indent(&self) -> Option` - **Description**: Returns the amount the first line of text in a block-level element is indented. Only applicable to paragraph-like elements with non-block-level elements. #### set_text_indent(text_indent: Option) - **Signature**: `pub fn set_text_indent(&mut self, text_indent: Option)` - **Description**: Sets the amount the first line of text in a block-level element is indented. Only applicable to paragraph-like elements with non-block-level elements. - **Parameters**: - `text_indent` (Option) - The indent value to set. #### with_text_indent(text_indent: Option) -> Self - **Signature**: `pub fn with_text_indent(mut self, text_indent: Option) -> Self` - **Description**: Sets the amount the first line of text in a block-level element is indented and returns the modified instance. Only applicable to paragraph-like elements with non-block-level elements. - **Parameters**: - `text_indent` (Option) - The indent value to set. #### text_align() - **Signature**: `pub fn text_align(&self) -> Option` - **Description**: Returns the text alignment. #### set_text_align(text_align: Option) - **Signature**: `pub fn set_text_align(&mut self, text_align: Option)` - **Description**: Sets the text alignment. - **Parameters**: - `text_align` (Option) - The alignment value to set. #### with_text_align(text_align: Option) -> Self - **Signature**: `pub fn with_text_align(mut self, text_align: Option) -> Self` - **Description**: Sets the text alignment and returns the modified instance. - **Parameters**: - `text_align` (Option) - The alignment value to set. ``` -------------------------------- ### start_indent Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the spacing between the start inline edge of the element and the parent. ```APIDOC ## start_indent ### Description Get or set the spacing between the start inline edge of the element and the parent. ### Methods - `pub fn start_indent(&self) -> Option` - Returns the current start indent. - `pub fn set_start_indent(&mut self, start_indent: Option)` - Sets the start indent. - `pub fn with_start_indent(mut self, start_indent: Option) -> Self` - Sets the start indent and returns the modified tag. ### Parameters - `start_indent` (Option) - The spacing to set. Use None to remove. ### Returns - `Option` - The current start indent, if set. ``` -------------------------------- ### height Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the height of the tag. ```APIDOC ## height ### Description Get or set the height of the tag. ### Methods - `pub fn height(&self) -> Option` - Returns the current height. - `pub fn set_height(&mut self, height: Option)` - Sets the height. - `pub fn with_height(mut self, height: Option) -> Self` - Sets the height and returns the modified tag. ### Parameters - `height` (Option) - The height to set. Use None to remove. ### Returns - `Option` - The current height, if set. ``` -------------------------------- ### Create a PDF document with krilla Source: https://docs.rs/krilla/latest/index.html This example demonstrates creating a two-page PDF document. The first page includes text with varying font sizes and colors, while the second page features a triangle with a linear gradient fill. ```rust use std::path::{self, PathBuf}; use krilla::color::rgb; use krilla::text::Font; use krilla::geom::{Point, PathBuilder}; use krilla::paint::{SpreadMethod, LinearGradient, Stop, FillRule}; use krilla::text::TextDirection; use krilla::paint::Fill; use krilla::Document; use krilla::page::PageSettings; use krilla::num::NormalizedF32; // Create a new document. let mut document = Document::new(); // Load a font. let font = { let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/fonts/NotoSans-Regular.ttf"); let data = std::fs::read(&path).unwrap(); Font::new(data.into(), 0).unwrap() }; // Add a new page with dimensions 200x200. let mut page = document.start_page_with(PageSettings::from_wh(200.0, 200.0).unwrap()); // Get the surface of the page. let mut surface = page.surface(); // Draw some text. surface.draw_text( Point::from_xy(0.0, 25.0), font.clone(), 14.0, "This text has font size 14!", false, TextDirection::Auto ); surface.set_fill(Some(Fill { paint: rgb::Color::new(255, 0, 0).into(), opacity: NormalizedF32::new(0.5).unwrap(), rule: Default::default(), })); // Draw some more text, in a different color with an opacity and bigger font size. surface.draw_text( Point::from_xy(0.0, 50.0), font.clone(), 16.0, "This text has font size 16!", false, TextDirection::Auto ); // Finish the page. surface.finish(); page.finish(); // Start a new page. let mut page = document.start_page_with(PageSettings::from_wh(200.0, 200.0).unwrap()); // Create the triangle. let triangle = { let mut pb = PathBuilder::new(); pb.move_to(100.0, 20.0); pb.line_to(160.0, 160.0); pb.line_to(40.0, 160.0); pb.close(); pb.finish().unwrap() }; // Create the linear gradient. let lg = LinearGradient { x1: 60.0, y1: 0.0, x2: 140.0, y2: 0.0, transform: Default::default(), spread_method: SpreadMethod::Repeat, stops: vec![ Stop { offset: NormalizedF32::new(0.2).unwrap(), color: rgb::Color::new(255, 0, 0).into(), opacity: NormalizedF32::ONE, }, Stop { offset: NormalizedF32::new(0.8).unwrap(), color: rgb::Color::new(255, 255, 0).into(), opacity: NormalizedF32::ONE, }, ], anti_alias: false, }; let mut surface = page.surface(); // Set the fill. surface.set_fill(Some(Fill { paint: lg.into(), rule: FillRule::EvenOdd, opacity: NormalizedF32::ONE })); // Fill the path. surface.draw_path(&triangle); // Finish up and write the resulting PDF. surface.finish(); page.finish(); let pdf = document.finish().unwrap(); let path = path::absolute("basic.pdf").unwrap(); eprintln!("Saved PDF to '{}'", path.display()); // Write the PDF to a file. std::fs::write(path, &pdf).unwrap(); ``` -------------------------------- ### width Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the width of the tag. ```APIDOC ## width ### Description Get or set the width of the tag. ### Methods - `pub fn width(&self) -> Option` - Returns the current width. - `pub fn set_width(&mut self, width: Option)` - Sets the width. - `pub fn with_width(mut self, width: Option) -> Self` - Sets the width and returns the modified tag. ### Parameters - `width` (Option) - The width to set. Use None to remove. ### Returns - `Option` - The current width, if set. ``` -------------------------------- ### ConfigurationBuilder::new Source: https://docs.rs/krilla/latest/krilla/configure/struct.ConfigurationBuilder.html Creates a new ConfigurationBuilder with default settings. ```APIDOC ## ConfigurationBuilder::new ### Description Creates a new ConfigurationBuilder with default settings. ### Method new ### Signature pub fn new() -> Self ### Parameters None ### Returns - **Self** - A new ConfigurationBuilder instance with default settings. ``` -------------------------------- ### border_color Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Gets the border color of the element. ```APIDOC ## border_color ### Description Gets the border color of the element. ### Method border_color ### Parameters None ### Returns Option> ``` -------------------------------- ### TilingPattern::new constructor Source: https://docs.rs/krilla/latest/src/krilla/graphics/tiling_pattern.rs.html Creates a new TilingPattern, applying opacity simulation if the base opacity is not set to one. ```rust pub(crate) fn new( stream: Stream, transform: Transform, base_opacity: NormalizedF32, width: f32, height: f32, serializer_context: &mut SerializeContext, chunk_container: &mut ChunkContainer, ) -> Self { // stroke/fill opacity doesn't work consistently across different viewers for patterns, // so instead we simulate it ourselves. let pattern_stream = if base_opacity == NormalizedF32::ONE { stream } else { let stream = { let mut builder = StreamBuilder::new(serializer_context, chunk_container); let mut surface = builder.surface(); surface.draw_opacified_stream(base_opacity, stream); surface.finish(); builder.finish() }; stream }; Self { stream: pattern_stream, transform, base_opacity, width, height, } } ``` -------------------------------- ### TagKind::location Source: https://docs.rs/krilla/latest/krilla/tagging/enum.TagKind.html Gets the location of the tag. ```APIDOC ## location ### Description Gets the location of the tag. ### Method pub fn location(&self) -> Option ### Parameters None ### Returns - **Option** - The location, if set. ``` -------------------------------- ### space_after Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the spacing after the block-level element. ```APIDOC ## space_after ### Description Get or set the spacing after the block-level element. ### Methods - `pub fn space_after(&self) -> Option` - Returns the current spacing after. - `pub fn set_space_after(&mut self, space_after: Option)` - Sets the spacing after. - `pub fn with_space_after(mut self, space_after: Option) -> Self` - Sets the spacing after and returns the modified tag. ### Parameters - `space_after` (Option) - The spacing to set. Use None to remove. ### Returns - `Option` - The current spacing after, if set. ``` -------------------------------- ### PageSettings::from_wh Source: https://docs.rs/krilla/latest/krilla/page/struct.PageSettings.html Attempts to create new page settings with the specified width and height. Returns None if either dimension is not greater than zero. ```APIDOC ## PageSettings::from_wh ### Description Try to create new page settings with the specified width and height. Returns None if either the width or the height is not > 0. ### Method Constructor ### Signature pub fn from_wh(width: f32, height: f32) -> Option ### Parameters - **width** (f32) - Required - The width of the page. - **height** (f32) - Required - The height of the page. ### Returns - **Option** - Some(PageSettings) if both width and height are greater than zero, otherwise None. ``` -------------------------------- ### space_before Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the spacing before the block-level element. ```APIDOC ## space_before ### Description Get or set the spacing before the block-level element. ### Methods - `pub fn space_before(&self) -> Option` - Returns the current spacing before. - `pub fn set_space_before(&mut self, space_before: Option)` - Sets the spacing before. - `pub fn with_space_before(mut self, space_before: Option) -> Self` - Sets the spacing before and returns the modified tag. ### Parameters - `space_before` (Option) - The spacing to set. Use None to remove. ### Returns - `Option` - The current spacing before, if set. ``` -------------------------------- ### Output::display Source: https://docs.rs/krilla/latest/krilla/tagging/enum.Placement.html Creates a Displayable wrapper for the Placement value. ```APIDOC ## Output::display ### Description Creates a Displayable wrapper for the Placement value. ### Method display ### Signature fn display<'a>(&'a self) -> Wrapper<'a, Self> ### Returns Wrapper<'a, Self> - A Displayable wrapper. ``` -------------------------------- ### Surface::get_stroke Source: https://docs.rs/krilla/latest/krilla/surface/struct.Surface.html Gets the currently active stroke. ```APIDOC ## Surface::get_stroke ### Description Gets the currently active stroke. ### Method get_stroke ### Signature pub fn get_stroke(&mut self) -> Option<&Stroke> ### Parameters None ### Returns - **Option<&Stroke>** - The currently active stroke, or None if no stroke is set. ``` -------------------------------- ### Surface::get_fill Source: https://docs.rs/krilla/latest/krilla/surface/struct.Surface.html Gets the currently active fill. ```APIDOC ## Surface::get_fill ### Description Gets the currently active fill. ### Method get_fill ### Signature pub fn get_fill(&mut self) -> Option<&Fill> ### Parameters None ### Returns - **Option<&Fill>** - The currently active fill, or None if no fill is set. ``` -------------------------------- ### Configuration::version Source: https://docs.rs/krilla/latest/krilla/configure/struct.Configuration.html Returns the PDF version of the configuration. ```APIDOC ## Configuration::version ### Description Returns the PDF version of the configuration. ### Method pub fn version(self) -> PdfVersion ### Parameters - self (Configuration) - The configuration instance. ### Returns - PdfVersion - The PDF version of the configuration. ``` -------------------------------- ### NaiveRgbColor::new Source: https://docs.rs/krilla/latest/krilla/tagging/struct.NaiveRgbColor.html Creates a new NaiveRgbColor from u8 red, green, and blue components. ```APIDOC ## NaiveRgbColor::new ### Description Creates a new RGB color with the given red, green, and blue components as u8 values. ### Method pub fn new(red: u8, green: u8, blue: u8) -> Self ### Parameters - **red** (u8) - Required - The red component of the color. - **green** (u8) - Required - The green component of the color. - **blue** (u8) - Required - The blue component of the color. ### Returns - **Self** - A new NaiveRgbColor instance. ``` -------------------------------- ### text_decoration_type Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Gets, sets, or chains the kind of text decoration. ```APIDOC ## text_decoration_type ### Description Gets, sets, or chains the kind of text decoration. ### Methods - `text_decoration_type(&self) -> Option` - Returns the current text decoration type. - `set_text_decoration_type(&mut self, text_decoration_type: Option)` - Sets the text decoration type. - `with_text_decoration_type(mut self, text_decoration_type: Option) -> Self` - Sets the text decoration type and returns the modified struct for chaining. ### Parameters - `text_decoration_type` (Option) - The type to set, or None to remove the attribute. ### Returns - `Option` - The current text decoration type, if set. - `Self` - The modified struct for chaining (with_ method). ``` -------------------------------- ### start_indent Source: https://docs.rs/krilla/latest/krilla/tagging/enum.TagKind.html Returns the spacing between the start inline edge of the element and the parent. ```APIDOC ## start_indent ### Description Returns the spacing between the start inline edge of the element and the parent. ### Method start_indent ### Signature pub fn start_indent(&self) -> Option ### Returns Option - The start indent. ``` -------------------------------- ### PageSettings::new Source: https://docs.rs/krilla/latest/krilla/page/struct.PageSettings.html Creates new page settings with the specified size. ```APIDOC ## PageSettings::new ### Description Creates new page settings and defines the size of the page surface. ### Method Constructor ### Signature pub fn new(size: Size) -> Self ### Parameters - **size** (Size) - Required - The size of the page surface. ### Returns - **Self** - The new PageSettings instance. ``` -------------------------------- ### unwrap basic usage Source: https://docs.rs/krilla/latest/krilla/error/type.KrillaResult.html Demonstrates the basic usage of unwrap to extract an Ok value. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` -------------------------------- ### text_decoration_thickness Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Gets, sets, or chains the width of the text decoration line. ```APIDOC ## text_decoration_thickness ### Description Gets, sets, or chains the width of the text decoration line. ### Methods - `text_decoration_thickness(&self) -> Option` - Returns the current text decoration thickness. - `set_text_decoration_thickness(&mut self, text_decoration_thickness: Option)` - Sets the text decoration thickness. - `with_text_decoration_thickness(mut self, text_decoration_thickness: Option) -> Self` - Sets the text decoration thickness and returns the modified struct for chaining. ### Parameters - `text_decoration_thickness` (Option) - The thickness to set, or None to remove the attribute. ### Returns - `Option` - The current text decoration thickness, if set. - `Self` - The modified struct for chaining (with_ method). ``` -------------------------------- ### Using and_then with filesystem metadata Source: https://docs.rs/krilla/latest/krilla/error/type.KrillaResult.html Shows how to chain metadata retrieval and modification time access. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Metadata::new Source: https://docs.rs/krilla/latest/krilla/metadata/struct.Metadata.html Creates a new Metadata instance with default values. ```APIDOC ## Metadata::new ### Description Creates new metadata for a PDF document. ### Method new() -> Self ### Parameters None ### Returns A new Metadata instance. ``` -------------------------------- ### Initialize PageLabelContainer Source: https://docs.rs/krilla/latest/src/krilla/page.rs.html Creates a new PageLabelContainer, returning None if all provided labels are empty. ```rust impl<'a> PageLabelContainer<'a> { pub(crate) fn new(labels: &'a [PageLabel]) -> Option { if labels.iter().all(|f| f.is_empty()) { None } else { Some(PageLabelContainer { labels }) } } ``` -------------------------------- ### end_indent Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Get or set the spacing between the end inline edge of the element and the parent. ```APIDOC ## end_indent ### Description Get or set the spacing between the end inline edge of the element and the parent. ### Methods - `pub fn end_indent(&self) -> Option` - Returns the current end indent. - `pub fn set_end_indent(&mut self, end_indent: Option)` - Sets the end indent. - `pub fn with_end_indent(mut self, end_indent: Option) -> Self` - Sets the end indent and returns the modified tag. ### Parameters - `end_indent` (Option) - The spacing to set. Use None to remove. ### Returns - `Option` - The current end indent, if set. ``` -------------------------------- ### Document::start_page Source: https://docs.rs/krilla/latest/krilla/document/index.html Starts a new page in the PDF document. This method returns a Page object that mutably borrows the document's global state, allowing you to add content to the page. Once the page is dropped, the global state is returned to the document. ```APIDOC ## Document::start_page ### Description Starts a new page in the PDF document. This method returns a Page object that mutably borrows the document's global state, allowing you to add content to the page. Once the page is dropped, the global state is returned to the document. ### Method start_page ### Endpoint Document::start_page ### Parameters None documented. ### Request Example None documented. ### Response #### Success Response Returns a Page object that mutably borrows the document's global state. #### Response Example None documented. ``` -------------------------------- ### Document::new_with Source: https://docs.rs/krilla/latest/krilla/document/struct.Document.html Creates a new Document with custom serialize settings. ```APIDOC ## Document::new_with ### Description Creates a new PDF document with custom serialize settings. ### Method new_with ### Signature pub fn new_with(serialize_settings: SerializeSettings) -> Self ### Parameters - **serialize_settings** (SerializeSettings) - Required - The serialize settings to use for the document. ### Returns Self - A new Document instance. ``` -------------------------------- ### glyph_orientation_vertical Source: https://docs.rs/krilla/latest/src/krilla/interchange/tagging/generated.rs.html Gets, sets, or chains how glyphs are rotated in a vertical writing mode. ```APIDOC ## glyph_orientation_vertical ### Description Gets, sets, or chains how glyphs are rotated in a vertical writing mode. ### Methods - `glyph_orientation_vertical(&self) -> Option` - Returns the current glyph orientation. - `set_glyph_orientation_vertical(&mut self, glyph_orientation_vertical: Option)` - Sets the glyph orientation. - `with_glyph_orientation_vertical(mut self, glyph_orientation_vertical: Option) -> Self` - Sets the glyph orientation and returns the modified struct for chaining. ### Parameters - `glyph_orientation_vertical` (Option) - The orientation to set, or None to remove the attribute. ### Returns - `Option` - The current glyph orientation, if set. - `Self` - The modified struct for chaining (with_ method). ``` -------------------------------- ### Product implementation for Result Source: https://docs.rs/krilla/latest/krilla/error/type.KrillaResult.html Demonstrates using the product method on an iterator of Results, which returns an Err if any element is an Err, or the product of all elements otherwise. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### FromIterator error collection Source: https://docs.rs/krilla/latest/krilla/error/type.KrillaResult.html Example of collecting a vector of Results where an error occurs. ```rust let v = vec![1, 2, 0]; let res: Result, &'static str> = v.iter().map(|x: &u32| x.checked_sub(1).ok_or("Underflow!") ).collect(); assert_eq!(res, Err("Underflow!")); ``` -------------------------------- ### Tag
  • ::set_start_indent Source: https://docs.rs/krilla/latest/krilla/tagging/struct.Tag.html Sets the spacing between the start inline edge of the element and the parent. ```APIDOC ## Tag
  • ::set_start_indent ### Description Sets the spacing between the start inline edge of the element and the parent. ### Signature pub fn set_start_indent(&mut self, start_indent: Option) ``` -------------------------------- ### NaiveRgbColor::new_f32 Source: https://docs.rs/krilla/latest/krilla/tagging/struct.NaiveRgbColor.html Creates a new NaiveRgbColor from normalized floating point red, green, and blue components. ```APIDOC ## NaiveRgbColor::new_f32 ### Description Creates a new RGB color from normalized floating point values for red, green, and blue components. ### Method pub fn new_f32(red: f32, green: f32, blue: f32) -> Self ### Parameters - **red** (f32) - Required - The red component of the color as a normalized float. - **green** (f32) - Required - The green component of the color as a normalized float. - **blue** (f32) - Required - The blue component of the color as a normalized float. ### Returns - **Self** - A new NaiveRgbColor instance. ``` -------------------------------- ### Tag::set_start_indent Source: https://docs.rs/krilla/latest/krilla/tagging/struct.Tag.html Sets the spacing between the start inline edge of the element and the parent. ```APIDOC ## Tag::set_start_indent ### Description Sets the spacing between the start inline edge of the element and the parent. ### Method pub fn set_start_indent(&mut self, start_indent: Option) ### Parameters - **start_indent** (Option) - Required - The start indent. ``` -------------------------------- ### Document::new Source: https://docs.rs/krilla/latest/krilla/document/struct.Document.html Creates a new Document with default serialize settings. ```APIDOC ## Document::new ### Description Creates a new PDF document with default serialize settings. ### Method new ### Signature pub fn new() -> Self ### Parameters None ### Returns Self - A new Document instance. ``` -------------------------------- ### Configuration and ConfigurationBuilder implementation Source: https://docs.rs/krilla/latest/src/krilla/configure/mod.rs.html Defines the Configuration struct for storing settings and the ConfigurationBuilder for constructing valid configurations with validation checks. ```rust 1//! Configuring PDF version and export mode. pub mod validate; mod version; pub use validate::{Accessibility, Archival, ValidationError, Validator, Validators}; pub use version::PdfVersion; use crate::configure::validate::ValidatorsBuilder; /// A configuration of validator and PDF version. #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub struct Configuration { validators: Validators, version: PdfVersion, } impl Configuration { /// Return the validators of the configuration. pub fn validators(self) -> Validators { self.validators } /// Return the PDF version of the configuration. pub fn version(self) -> PdfVersion { self.version } } /// A configuration of validator and PDF version. #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub struct ConfigurationBuilder { validators: ValidatorsBuilder, version: Option, } impl ConfigurationBuilder { /// Create a new `ConfigurationBuilder` with default settings. pub fn new() -> Self { Self::default() } /// Set the PDF version, overwriting the current one if already set. pub fn with_version(mut self, version: PdfVersion) -> Self { self.version = Some(version); self } /// Set a validator, overwriting the current one if the same standard family is already set. pub fn set_validator(mut self, validator: Validator) -> Self { self.validators = self.validators.set_validator(validator); self } /// Set the PDF/A validator, overwriting the current one if already set. pub fn with_archival_validator(mut self, archival: Archival) -> Self { self.validators = self.validators.with_archival_validator(archival); self } /// Set the PDF/UA accessibility validator, overwriting the current one if already set. pub fn with_accessibility_validator(mut self, ua: Accessibility) -> Self { self.validators = self.validators.with_accessibility_validator(ua); self } /// Build the [`Configuration`], returning an error if the validators and version are incompatible. pub fn finish(self) -> Result { let validators = self .validators .finish() .map_err(ConfigurationError::NoOverlappingValidatorsRange)?; let validator_range = validators.min().unwrap_or(PdfVersion::MIN)..=validators.max(); match self.version { Some(version) if validator_range.contains(&version) => Ok(Configuration { validators, version, }), Some(version) => Err(ConfigurationError::VersionDoesNotMatchValidatorsRange( version, validators, )), None if !validators.is_empty() => Ok(Configuration { validators, version: *validator_range.end(), }), None => { let version = PdfVersion::default(); debug_assert!(validator_range.contains(&version)); Ok(Configuration { validators, version, }) } } } } ``` -------------------------------- ### Tag::set_start_indent Source: https://docs.rs/krilla/latest/krilla/tagging/struct.Tag.html Sets the spacing between the start inline edge of the element and the parent. ```APIDOC ## Tag::set_start_indent ### Description Sets the spacing between the start inline edge of the element and the parent. ### Method Setter ### Signature pub fn set_start_indent(&mut self, start_indent: Option) ### Parameters - **start_indent** (Option) - Required - The new spacing between the start inline edge of the element and the parent. ``` -------------------------------- ### PathBuilder::close Source: https://docs.rs/krilla/latest/krilla/geom/struct.PathBuilder.html Closes the current contour, connecting the last point back to the start. ```APIDOC ## PathBuilder::close ### Description Closes the current contour. ### Signature pub fn close(&mut self) ### Parameters None ### Returns None ```