Struct pdf::Canvas
[−]
[src]
pub struct Canvas<'a> { // some fields omitted }
An visual area where content can be drawn (a page).
Provides methods for defining and stroking or filling paths, as well as placing text objects.
TODO Everything here that takes a BuiltinFont
should take any
FontSource
instead.
Methods
impl<'a> Canvas<'a>
[src]
fn new(output: &'a mut Write, fonts: &'a mut HashMap<BuiltinFont, FontRef>, outline_items: &'a mut Vec<OutlineItem>) -> Canvas<'a>
TODO Should not public outside crate.
fn rectangle(&mut self, x: f32, y: f32, width: f32, height: f32) -> Result<()>
Append a closed rectangle with a corner at (x, y) and extending width × height to the to the current path.
fn set_line_join_style(&mut self, style: JoinStyle) -> Result<()>
Set the line join style in the graphics state.
fn set_line_cap_style(&mut self, style: CapStyle) -> Result<()>
Set the line join style in the graphics state.
fn set_line_width(&mut self, w: f32) -> Result<()>
Set the line width in the graphics state.
fn set_stroke_color(&mut self, color: Color) -> Result<()>
Set color for stroking operations.
fn set_fill_color(&mut self, color: Color) -> Result<()>
Set color for non-stroking operations.
fn concat(&mut self, m: Matrix) -> Result<()>
Modify the current transformation matrix for coordinates by concatenating the specified matrix.
fn line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> Result<()>
Append a straight line from (x1, y1) to (x2, y2) to the current path.
fn move_to(&mut self, x: f32, y: f32) -> Result<()>
Begin a new subpath at the point (x, y).
fn line_to(&mut self, x: f32, y: f32) -> Result<()>
Add a straight line from the current point to (x, y) to the current path.
fn curve_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32) -> Result<()>
Add an Bézier curve from the current point to (x3, y3) with (x1, y1) and (x2, y2) as Bézier controll points.
fn circle(&mut self, x: f32, y: f32, r: f32) -> Result<()>
Add a circle approximated by four cubic Bézier curves to the current path. Based on http://spencermortensen.com/articles/bezier-circle/
fn stroke(&mut self) -> Result<()>
Stroke the current path.
fn close_and_stroke(&mut self) -> Result<()>
Close and stroke the current path.
fn fill(&mut self) -> Result<()>
Fill the current path.
fn get_font(&mut self, font: BuiltinFont) -> FontRef
Get a FontRef for a specific font.
fn text<F, T>(&mut self, render_text: F) -> Result<T> where F: FnOnce(&mut TextObject) -> Result<T>
Create a text object.
The contents of the text object is defined by the function render_text, by applying methods to the TextObject it gets as an argument. On success, return the value returned by render_text.
fn left_text(&mut self, x: f32, y: f32, font: BuiltinFont, size: f32, text: &str) -> Result<()>
Utility method for placing a string of text.
fn right_text(&mut self, x: f32, y: f32, font: BuiltinFont, size: f32, text: &str) -> Result<()>
Utility method for placing a string of text.
fn center_text(&mut self, x: f32, y: f32, font: BuiltinFont, size: f32, text: &str) -> Result<()>
Utility method for placing a string of text.
fn add_outline(&mut self, title: &str)
Add an item for this page in the document outline.
An outline item associates a name (contained in an ordered tree) with a location in the document. The PDF standard supports several ways to specify an exact location on a page, but this implementation currently only supports linking to a specific page (the page that this Canvas is for).
fn gsave(&mut self) -> Result<()>
Save the current graphics state. The caller is responsible for restoring it later.
fn grestore(&mut self) -> Result<()>
Restor the current graphics state. The caller is responsible for having saved it earlier.