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>
fn rectangle(&mut self, x: f32, y: f32, width: f32, height: f32) -> Result<()>
Append a closed rectangle with a corern at (x, y) and extending width × height to the to the current path.
fn set_line_width(&mut self, w: f32) -> Result<()>
Set the line width in the graphics state
fn set_stroke_color(&mut self, r: u8, g: u8, b: u8) -> Result<()>
Set rgb color for stroking operations
fn set_fill_color(&mut self, r: u8, g: u8, b: u8) -> Result<()>
Set rgb color for non-stroking operations
fn set_stroke_gray(&mut self, gray: u8) -> Result<()>
Set gray level for stroking operations
fn set_fill_gray(&mut self, gray: u8) -> Result<()>
Set gray level for non-stroking operations
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 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.
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 OutlineItem 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).