pub struct Fpdf<'a> { /* private fields */ }Expand description
Fpdf is the principal structure for creating a single PDF document.
It holds all the neccessary information for constructing a PDF document, with all images, attachments, bookmarks etc.
§Example
use fpdf::Fpdf;
let mut pdf = Fpdf::default();Implementations§
Source§impl<'a> Fpdf<'a>
impl<'a> Fpdf<'a>
Sourcepub fn new(
orientation: Orientation,
page_size: PageSize,
font_dir: &str,
size_v: UnitVec2,
) -> Self
pub fn new( orientation: Orientation, page_size: PageSize, font_dir: &str, size_v: UnitVec2, ) -> Self
Examples found in repository?
examples/example_set_line_join_style.rs (line 5)
3fn main() {
4 const OFFSET: Unit = Unit::mm(75.0);
5 let mut pdf = Fpdf::new(Orientation::Landscape, PageSize::A4, "", UnitVec2::default());
6 pdf.add_page();
7 let draw = |pdf: &mut Fpdf, cap: &str, join: &str, x0: f64, y0: f64, x1: f64, y1: f64| {
8 let x0 = Unit::mm(x0);
9 let y0 = Unit::mm(y0);
10 let x1 = Unit::mm(x1);
11 let y1 = Unit::mm(y1);
12
13 pdf.set_line_cap_style(cap);
14 pdf.set_line_join_style(join);
15
16 pdf.set_draw_color(RGB::new(0x33, 0x33, 0x33));
17 pdf.set_line_width(Unit::mm(30.0));
18 pdf.move_to(x0, y0);
19 pdf.line_to((x0+x1) / 2.0 + OFFSET, (y0+y1)/2.0);
20 pdf.line_to(x1, y1);
21 pdf.draw_path("D");
22
23 pdf.set_draw_color(RGB::new(0xFF, 0x33, 0x33));
24 pdf.set_line_width(Unit::mm(2.56));
25 pdf.move_to(x0, y0);
26 pdf.line_to((x0+x1)/2.0+OFFSET, (y0+y1)/2.0);
27 pdf.line_to(x1, y1);
28 pdf.draw_path("D");
29 };
30 let mut x = 35.0;
31 let caps = ["butt", "square", "round"];
32 let joins = ["bevel", "miter", "round"];
33 for i in 0..3 {
34 draw(&mut pdf, caps[i], joins[i], x, 50.0, x, 160.0);
35 x += OFFSET.to_mm();
36 }
37 pdf.output_file_and_close("example_set_line_join_style.pdf").unwrap();
38}More examples
examples/example_page_size.rs (lines 4-9)
3fn main() {
4 let mut pdf = Fpdf::new(
5 Orientation::Portrait,
6 PageSize::A4,
7 "",
8 UnitVec2::inch(6.0, 6.0),
9 );
10 pdf.set_margins(Unit::inch(0.5), Unit::inch(1.0), Unit::inch(0.5));
11 pdf.set_font("Times", "", Unit::pt(14.0));
12 pdf.add_page_format(Orientation::Landscape, UnitVec2::inch(3.0, 12.0));
13 pdf.set_xy(Unit::inch(0.5), Unit::inch(1.5));
14 pdf.cell_format(
15 Unit::inch(11.0),
16 Unit::inch(0.2),
17 "12 in times 3 in",
18 "",
19 0,
20 "C",
21 false,
22 0,
23 "",
24 );
25 pdf.add_page();
26 pdf.set_xy(Unit::inch(0.5), Unit::inch(3.0));
27 pdf.cell_format(
28 Unit::inch(5.0),
29 Unit::inch(0.2),
30 "6 in times 6 in",
31 "",
32 0,
33 "C",
34 false,
35 0,
36 "",
37 );
38 pdf.add_page_format(Orientation::Portrait, UnitVec2::inch(3.0, 12.0));
39 pdf.set_xy(Unit::inch(0.5), Unit::inch(6.0));
40 pdf.cell_format(
41 Unit::inch(2.0),
42 Unit::inch(0.2),
43 "3 in times 12 in",
44 "",
45 0,
46 "C",
47 false,
48 0,
49 "",
50 );
51 for i in 0..3 {
52 let page_size = pdf.page_size(i);
53 println!(
54 "{} in times {} in",
55 page_size.width().to_inch(),
56 page_size.height().to_inch()
57 );
58 }
59 pdf.output_file_and_close("example_page_size.pdf").unwrap();
60}examples/example_set_accept_page_break_fn.rs (lines 36-41)
14fn main() {
15 const WIDTH: Unit = Unit::mm(297.0);
16 const GUTTER: usize = 4;
17 const COLS: usize = 3;
18
19 let current_col = Rc::new(RefCell::new(0usize));
20 let y0 = Rc::new(RefCell::new(Unit::mm(0.0)));
21 let col_width: Unit =
22 (WIDTH - MARGIN.mul_untouched(2.0) - Unit::mm(((COLS - 1) * GUTTER) as f64))
23 .div_untouched(COLS as f64);
24 let lorem = LOREM_PARTS.join(" ");
25
26 let set_col = |pdf: &mut Fpdf, col: usize| {
27 let mut current_col = current_col.borrow_mut();
28 *current_col = col;
29 let x = MARGIN
30 + col_width
31 .add_untouched(GUTTER as f64)
32 .mul_untouched(col as f64);
33 pdf.set_left_margin(x);
34 pdf.set_x(x);
35 };
36 let mut pdf = Fpdf::new(
37 Orientation::Landscape,
38 PageSize::A4,
39 "",
40 UnitVec2::default(),
41 );
42 pdf.set_catalog_sort(true);
43 pdf.set_compression(false);
44 pdf.set_header_fn(|pdf| {
45 let title = "fpdf-rs";
46 pdf.set_font("Helvetica", "B", Unit::pt(48.0));
47 let width = pdf.get_string_width(title).add_untouched(6.0);
48 pdf.set_x((WIDTH - width).div_untouched(2.0));
49 pdf.set_text_color(RGB::new(128, 128, 160));
50 pdf.write(Unit::mm(12.0), &title[..4]);
51 pdf.set_text_color(RGB::new(128, 128, 128));
52 pdf.write(Unit::mm(12.0), &title[4..5]);
53 pdf.set_text_color(RGB::new(170, 39, 4));
54 pdf.write(Unit::mm(12.0), &title[5..]);
55 pdf.ln(Unit::mm(20.0));
56 let mut y0 = y0.borrow_mut();
57 *y0 = pdf.get_y();
58 });
59 pdf.set_accept_page_break_fn(|pdf| -> bool {
60 let current_col = {
61 let cc = current_col.borrow();
62 *cc
63 };
64 if current_col < COLS - 1 {
65 set_col(pdf, current_col + 1);
66 let y0 = {
67 let y0 = y0.borrow();
68 *y0
69 };
70 pdf.set_y(y0);
71 false
72 } else {
73 set_col(pdf, 0);
74 true
75 }
76 });
77 pdf.add_page();
78 pdf.set_font("Times", "", Unit::pt(12.0));
79 for i in 0..20 {
80 if i == 1 {
81 pdf.image(
82 "examples/resources/fpdf.png",
83 Unit::negative(),
84 Unit::mm(0.0),
85 UnitVec2::mm(col_width.to_mm(), 0.0),
86 true,
87 ImageOptions::default_png(),
88 0,
89 "",
90 );
91 } else if i == 5 {
92 pdf.image(
93 "examples/resources/rust-ferris.png",
94 Unit::negative(),
95 Unit::mm(0.0),
96 UnitVec2::mm(col_width.to_mm(), 0.0),
97 true,
98 ImageOptions::default_png(),
99 0,
100 "",
101 );
102 }
103 pdf.multi_cell(col_width, Unit::mm(5.0), lorem.as_str(), "", "", false);
104 pdf.ln(Unit::negative());
105 }
106 pdf.output_file_and_close("example_set_accept_page_break_fn.pdf")
107 .unwrap();
108}Sourcepub fn svg_basic_file_parse(svg_file: &str) -> Result<SVGBasic>
pub fn svg_basic_file_parse(svg_file: &str) -> Result<SVGBasic>
Examples found in repository?
examples/example_svg_basic_write.rs (line 23)
13fn main() {
14 const FONT_SIZE: Unit = Unit::pt(16.0);
15 const WIDTH: Unit = Unit::mm(100.0);
16 const SVG_FILE_PATH: &'static str = "examples/resources/drawing.svg";
17
18 let mut pdf = Fpdf::default();
19 pdf.set_font("Times", "", FONT_SIZE);
20 pdf.add_page();
21 pdf.set_margins(Unit::mm(10.0), Unit::mm(10.0), Unit::mm(10.0));
22 pdf.write_basic_html(FONT_SIZE, HTML);
23 let svg_file = Fpdf::svg_basic_file_parse(SVG_FILE_PATH).unwrap();
24 let mut scale = 100.0 / svg_file.width;
25 let scale_y = 30.0 / svg_file.height;
26 if scale > scale_y {
27 scale = scale_y;
28 }
29 pdf.set_line_cap_style("round");
30 pdf.set_line_width(Unit::mm(0.25));
31 pdf.set_draw_color(RGB::new(0, 0, 128));
32 let y = pdf.get_y();
33 pdf.set_xy(Unit::mm(210.0 - scale * svg_file.width) / 2.0, y + 10.0);
34 pdf.svg_basic_write(&svg_file, Unit::mm(scale));
35 pdf.output_file_and_close("example_svg_basic_write.pdf")
36 .unwrap();
37}pub fn deserialize_template(b: Vec<u8>) -> Result<impl Template>
Trait Implementations§
Source§impl<'a> Pdf<'a> for Fpdf<'a>
impl<'a> Pdf<'a> for Fpdf<'a>
Source§fn add_attachment_annotation(
&mut self,
a: Rc<RefCell<Attachment>>,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
)
fn add_attachment_annotation( &mut self, a: Rc<RefCell<Attachment>>, x: Unit, y: Unit, w: Unit, h: Unit, )
Puts a link on the current page, on the rectangle defined by
x, y, w and h. This link points towards the content
defined in a, which is embedded in the document. Note that
no drawing is done by this method: a method like Pdf::cell
or Pdf::rect should be called to indicate to the reader,
that there is a link. Attachment pointing to the same data
will have their content only be included once, and shared
amongst all links. Read moreSource§fn add_font(
&mut self,
family: &str,
style: &str,
file: &str,
is_utf8: bool,
) -> Result<()>
fn add_font( &mut self, family: &str, style: &str, file: &str, is_utf8: bool, ) -> Result<()>
Source§fn add_font_from_bytes(
&mut self,
family: &str,
style: &str,
json_file_bytes: Vec<u8>,
z_file_bytes: Vec<u8>,
)
fn add_font_from_bytes( &mut self, family: &str, style: &str, json_file_bytes: Vec<u8>, z_file_bytes: Vec<u8>, )
Imports a TrueType, OpenType or Type1 font from static bytes within the
static executable and makes it available. Read more
fn add_font_from_reader(&mut self, family: &str, style: &str, r: Box<dyn Read>)
Source§fn add_layer(&mut self, name: &str, visible: bool) -> usize
fn add_layer(&mut self, name: &str, visible: bool) -> usize
Defines a layer that can be shown of hidden when the document is
displayed. Read more
Source§fn add_link(&mut self) -> usize
fn add_link(&mut self) -> usize
Creates a new internal link and returns its ID. An internal link is a
clickable area which directs to another place within the document. The
ID can then be passed to Pdf::cell, Pdf::write, Pdf::image, or
Pdf::link. The destination can be defined with Pdf::set_link.
Source§fn add_page(&mut self)
fn add_page(&mut self)
Adds a new page to the PDF document. If a page is already present, the
footer (see Pdf::set_footer_fn) callback function is called first to
output the footer. Then the page is added, the current position is set
to the top-left corner according to the left and top margins, and the
header (see Pdf::set_header_fn) callback function is called to
display the header. Read moreSource§fn add_page_format(&mut self, orientation: Orientation, size: UnitVec2)
fn add_page_format(&mut self, orientation: Orientation, size: UnitVec2)
Adds a new page with non-default page size and orientation. See Pdf::add_page
for more details.
Source§fn alias_nb_pages(&mut self, alias: &str)
fn alias_nb_pages(&mut self, alias: &str)
Defines an alias for the total number of pages. It will be substituted
as the document is closed. An empty string is replaced with the string
“{nb}”.
Source§fn arc_to(
&mut self,
x: Unit,
y: Unit,
rx: Unit,
ry: Unit,
deg_rotate: f64,
deg_start: f64,
deg_end: f64,
)
fn arc_to( &mut self, x: Unit, y: Unit, rx: Unit, ry: Unit, deg_rotate: f64, deg_start: f64, deg_end: f64, )
Draws an elliptical arc centered at point (
x, y). rx and ry
specify its horizontal and vertical radii. If the start of the arc is
not at the current position, a connection line will be drawn. Read moreSource§fn arc(
&mut self,
x: Unit,
y: Unit,
rx: Unit,
ry: Unit,
deg_rotate: f64,
deg_start: f64,
deg_end: f64,
style: &str,
)
fn arc( &mut self, x: Unit, y: Unit, rx: Unit, ry: Unit, deg_rotate: f64, deg_start: f64, deg_end: f64, style: &str, )
Draws an elliptical arc centered at point (
x, y). rx and ry
specify its horizontal and vertical radii. Read moreSource§fn begin_layer(&mut self, id: usize)
fn begin_layer(&mut self, id: usize)
Add content to the specified layer. All content added to the page
between a call to Pdf::begin_layer and Pdf::end_layer is added to
the layer specified by
id. See Pdf::add_layer for more details.Source§fn beziergon(&mut self, points: &[UnitVec2], style: &str)
fn beziergon(&mut self, points: &[UnitVec2], style: &str)
Draws a closed figure defined by a series of cubic Bézier curve
segments. The first point in the slice defines the starting point of the
figure. Each three following points
p1, p2, p3 represent a curve
segment of the point p3 using p1 and p2 as the Bézier control
points. Read moreSource§fn bookmark(&mut self, y: Option<Unit>, text: &str, level: usize)
fn bookmark(&mut self, y: Option<Unit>, text: &str, level: usize)
Set a bookmark that will be displayed in a sidebar outline. Read more
Source§fn cell_format(
&mut self,
w: Unit,
h: Unit,
text: &str,
border: &str,
ln: isize,
align: &str,
fill: bool,
link: usize,
link_str: &str,
)
fn cell_format( &mut self, w: Unit, h: Unit, text: &str, border: &str, ln: isize, align: &str, fill: bool, link: usize, link_str: &str, )
Prints a rectangular cell with optional borders, background
color and character string. The upper-left corner of the cell
corresponds to the current position. The text can be aligned
or centered. After the call, the current position moves to the
right or the next line. It is possible to put a link on the
text. Read more
Source§fn cell(&mut self, w: Unit, h: Unit, text: &str)
fn cell(&mut self, w: Unit, h: Unit, text: &str)
A simpler version of Pdf::cell_format with no fill, border,
links or special alignment. Read more
Source§fn clear_error(&mut self)
fn clear_error(&mut self)
Unsets the internal FPDF error. This method should be used
with care, as an internal error condition usually indicates an
unrecoverable problem with the generation of a document. It is
intended to deal with cases in which an error is used to
select an alternate form of the document.
Source§fn clip_end(&mut self)
fn clip_end(&mut self)
Ends a clipping operation that was previously started with a
call to Pdf::clip_rect, Pdf::clip_rounded_rect,
Pdf::clip_text, Pdf::clip_ellipse, Pdf::clip_circle or
Pdf::clip_polygon. Read more
Source§fn clip_polygon(&mut self, points: &[UnitVec2], outline: bool)
fn clip_polygon(&mut self, points: &[UnitVec2], outline: bool)
Begins a clipped operation within a polygon. The figure is
defined by a series of vertices specified by points. The last
point in the slice will be implicitly joined to the first to
close the polygon. Read more
Source§fn clip_rect(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, outline: bool)
fn clip_rect(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, outline: bool)
Begins a rectangular clipping operation. Read more
Source§fn clip_rounded_rect(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
r: Unit,
outline: bool,
)
fn clip_rounded_rect( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, r: Unit, outline: bool, )
Begins a rectangular clipping operation. Read more
Source§fn clip_rounded_rect_ext(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
rtl: Unit,
rtr: Unit,
rbr: Unit,
rbl: Unit,
outline: bool,
)
fn clip_rounded_rect_ext( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, rtl: Unit, rtr: Unit, rbr: Unit, rbl: Unit, outline: bool, )
This method behaves the same as Pdf::clip_rounded_rect, but
supports a different radius for each corner, given by the
arguments
rtl (top-left), rtr (top-right), rbr
(bottom-right), and rbl (bottom-left). See
Pdf::clip_rounded_rect for more details. Read moreSource§fn clip_text(&mut self, x: Unit, y: Unit, text: &str, outline: bool)
fn clip_text(&mut self, x: Unit, y: Unit, text: &str, outline: bool)
Begins a clipping operations in which rendering is confined to
the character string specified by
text. Read moreSource§fn close(&mut self)
fn close(&mut self)
Terminate the PDF document. It is not necessary to call this
method explicitly, because Pdf::output,
Pdf::output_and_close and Pdf::output_file_and_close do it
automatically. If the document contains no page,
Pdf::add_page is called to prevent the generation of an
invalid document.
Source§fn close_path(&mut self)
fn close_path(&mut self)
Creates a line from the current location to the last
Pdf::move_to location (if not the same) and mark the path as
closed, so the first and last lines join nicely. Read more
Source§fn create_template_custom(
&mut self,
corner: Vec2,
size: UnitVec2,
cb: impl FnMut(&mut Self, &mut Tpl<'_>) + 'a,
) -> impl Template
fn create_template_custom( &mut self, corner: Vec2, size: UnitVec2, cb: impl FnMut(&mut Self, &mut Tpl<'_>) + 'a, ) -> impl Template
Starts a template, using the given bounds.
Source§fn create_template(
&mut self,
cb: impl FnMut(&mut Tpl<'_>) + 'a,
) -> impl Template
fn create_template( &mut self, cb: impl FnMut(&mut Tpl<'_>) + 'a, ) -> impl Template
Defines a new template using the current page size.
Source§fn curve_bezier_cubic_to(
&mut self,
x: Unit,
y: Unit,
cx0: Unit,
cy0: Unit,
cx1: Unit,
cy1: Unit,
)
fn curve_bezier_cubic_to( &mut self, x: Unit, y: Unit, cx0: Unit, cy0: Unit, cx1: Unit, cy1: Unit, )
Creates a single-segment cubic Bézier curve. The curve starts
at the current stylus location and ends at the point (
x,
y). The control points (cx0, cy0) and (cx1, cy1)
specify the curvature. Read moreSource§fn curve_bezier_cubic(
&mut self,
x0: Unit,
y0: Unit,
cx0: Unit,
cy0: Unit,
x1: Unit,
y1: Unit,
cx1: Unit,
cy1: Unit,
style: &str,
)
fn curve_bezier_cubic( &mut self, x0: Unit, y0: Unit, cx0: Unit, cy0: Unit, x1: Unit, y1: Unit, cx1: Unit, cy1: Unit, style: &str, )
Creates a single-segment cubic Bézier curve. The curve starts
at the point (
x0, y0) and ends at the point (x1,
y1). The control points (cx0, cy0) and (cx1, cy1)
specify the curvature. Read moreSource§fn curve_to(&mut self, x: Unit, y: Unit, cx: Unit, cy: Unit)
fn curve_to(&mut self, x: Unit, y: Unit, cx: Unit, cy: Unit)
Creates a single-segment quadratic Bézier curve. The curve starts
at the current stylus location and ends at the point (
x,
y). The control point (cx, cy) specifies the
curvature. Read moreSource§fn curve(
&mut self,
x0: Unit,
y0: Unit,
x1: Unit,
y1: Unit,
cx: Unit,
cy: Unit,
style: &str,
)
fn curve( &mut self, x0: Unit, y0: Unit, x1: Unit, y1: Unit, cx: Unit, cy: Unit, style: &str, )
Draws a single-segment quadratic Bézier curve. The curve
starts at point (
x0, y0) and ends at the point (x1,
y1). The control point (cx0, cy0) specifies the
curvature. At the start point, the curve is tangent to the
straight line between the start point and the control
point. At the end point, the curve is tangent to the straight
line between the end point and the control point. Read moreSource§fn end_layer(&mut self)
fn end_layer(&mut self)
Is called to stop adding content to the currently active
layer. See Pdf::begin_layer for more details.
Source§fn error(&self) -> Result<()>
fn error(&self) -> Result<()>
Returns the internal FPDF error; it is of value Ok if no
error has occured.
Source§fn get_alpha(&self) -> (f64, Blend)
fn get_alpha(&self) -> (f64, Blend)
Returns the alpha blending channel, which consists of the
alpha transparency value and the blend mode. See
Pdf::set_alpha for more details.
Source§fn get_auto_page_break(&mut self) -> (bool, Unit)
fn get_auto_page_break(&mut self) -> (bool, Unit)
Source§fn get_cell_margin(&mut self) -> Unit
fn get_cell_margin(&mut self) -> Unit
Returns the cell margin. This is the amount of space before
and after a text within a cell that’s left blank. It defaults
to [Unit::Millimeter(1.0)].
Source§fn get_draw_color(&mut self) -> RGB
fn get_draw_color(&mut self) -> RGB
Returns the most recently set draw color as RGB components
(
0 - 255). This will not be the current value if a draw
color of some other type (e.g. spot) has been more recently
set.Source§fn get_draw_spot_color(&mut self) -> CMYKColorName
fn get_draw_spot_color(&mut self) -> CMYKColorName
Returns the most recently used spot color information for
drawing. This will not be the current drawing color if some
other color type, such as RGB is active. If no spot has been
set for drawing, then all values are set to [0].
Source§fn get_fill_color(&mut self) -> RGB
fn get_fill_color(&mut self) -> RGB
Returns the most recently set fill color as RGB components
(
0 - 255). This will not be the current value if a draw
color of some other type (e.g. spot) has been more recently
set.Source§fn get_fill_spot_color(&mut self) -> CMYKColorName
fn get_fill_spot_color(&mut self) -> CMYKColorName
Returns the most recently used spot color information for
fill output. This will not be the current drawing color if
some other color type, such as RGB is active. If no fill
spot color has been set, then all values are set to [0].
Source§fn get_font_desc(&mut self, family: &str, style: &str) -> FontDesc
fn get_font_desc(&mut self, family: &str, style: &str) -> FontDesc
Returns the font descriptor, which can be used for example to
find the baseline of a font. If
family is empty, the current
font descriptor will be returned. See FontDesc for
documentation about the font descriptor. See Pdf::add_font
for details about family and style.Source§fn get_font_size(&mut self) -> Unit
fn get_font_size(&mut self) -> Unit
Returns the size of the current font.
Source§fn get_image_info(&mut self, image: &str) -> Option<ImageInfo>
fn get_image_info(&mut self, image: &str) -> Option<ImageInfo>
Returns information about the registered image specified by
image. If the image has not been registered, None is
returned. The internal error is not modified by this method.Source§fn get_line_width(&mut self) -> Unit
fn get_line_width(&mut self) -> Unit
Returns the current line thickness.
Source§fn get_margins(&self) -> Margin
fn get_margins(&self) -> Margin
Returns the page margins.
Source§fn get_page_size_str(&mut self, size: &str) -> UnitVec2
fn get_page_size_str(&mut self, size: &str) -> UnitVec2
Returns the current page’s width
x and height y in
points. This is the paper’s size. To compute the size of
the area being used, subtract the margins (see
Pdf::get_margins).Source§fn get_page_size(&self) -> UnitVec2
fn get_page_size(&self) -> UnitVec2
Returns the current page’s width
x and height y. This is
the paper’s size. To compute the size of the area being used,
subtract the margins (see Pdf::get_margins).Source§fn get_string_symbol_width(&self, s: &str) -> Unit
fn get_string_symbol_width(&self, s: &str) -> Unit
Returns the length of a string in glyf units. A font must be
currently selected.
Source§fn get_string_width(&self, s: &str) -> Unit
fn get_string_width(&self, s: &str) -> Unit
Returns the length of a string in user units. A font must be
currently selected.
Source§fn get_text_color(&mut self) -> RGB
fn get_text_color(&mut self) -> RGB
Returns the most recently set text color as RGB components
(
0 - 255). This will not be the current value if a text
color of some other type (e.g. spot) has been more recently
set.Source§fn get_text_spot_color(&mut self) -> CMYKColorName
fn get_text_spot_color(&mut self) -> CMYKColorName
Returns the most recently used spot color information for text
output. This will not be the current text color if some other
color type such as RGB is active. If no spot color has been
set for text, then all values are set to [0].
Source§fn get_xy(&mut self) -> (Unit, Unit)
fn get_xy(&mut self) -> (Unit, Unit)
Returns the abscissa and ordinate of the current position. Read more
Source§fn image(
&mut self,
image_name: &str,
x: Unit,
y: Unit,
dimensions: UnitVec2,
flow: bool,
options: ImageOptions,
link: usize,
link_str: &str,
)
fn image( &mut self, image_name: &str, x: Unit, y: Unit, dimensions: UnitVec2, flow: bool, options: ImageOptions, link: usize, link_str: &str, )
Puts a JPEG, PNG or GIF image in the current page. Read more
Source§fn image_type_from_mime(&mut self, mime: &str) -> Result<ImageType>
fn image_type_from_mime(&mut self, mime: &str) -> Result<ImageType>
Returns the image type used in various image-related functions
(e.g. Pdf::image) that is associated with the specified MIME
type. For example, [Ok(ImageType::JPG)] is returned if
mime
is “image/jpeg”. An error is set if the specified MIME type is
not supported.Source§fn linear_gradient(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
rgb_from: RGB,
rgb_to: RGB,
)
fn linear_gradient( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, x1: f64, y1: f64, x2: f64, y2: f64, rgb_from: RGB, rgb_to: RGB, )
Draws a rectangular area with a blending of one color to
another. The rectangle is of width
w and height h. Its
upper left corner is positioned at point (x, y). Read moreSource§fn line_to(&mut self, x: Unit, y: Unit)
fn line_to(&mut self, x: Unit, y: Unit)
Creates a line from the current stylus location to (
x, y),
which becomes the new stylus location. Read moreSource§fn line(&mut self, x1: Unit, y1: Unit, x2: Unit, y2: Unit)
fn line(&mut self, x1: Unit, y1: Unit, x2: Unit, y2: Unit)
Draws a line between points (
x1, y1) and (x2, y2)
using the current draw color, line width and cap style.Source§fn link_string(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, link_str: &str)
fn link_string(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, link_str: &str)
Puts a link on a rectangular area of the page. Text or image
links are generally put via Pdf::cell, Pdf::write or
Pdf::image, but this method can be useful, for instance, to
define a clickable area inside an image.
link_str is the
target URL.Source§fn link(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, link: usize)
fn link(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, link: usize)
Puts a link on a rectangular area of the page. Text or image
links are generally put via Pdf::cell, Pdf::write or
Pdf::image, but this method can be useful, for instance, to
define a clickable area inside an image.
link is the value
returned by Pdf::add_link.Source§fn ln(&mut self, h: Unit)
fn ln(&mut self, h: Unit)
Performs a line break. The current abscissa goes back to the
left margin and the ordinate increases by the amount passed in
the parameter. A negative value for
h indicates the height
of the last printed cell. Read moreSource§fn move_to(&mut self, x: Unit, y: Unit)
fn move_to(&mut self, x: Unit, y: Unit)
Moves the stylus to (
x, y) without drawing the path from
the previous point. Paths must start with a Pdf::move_to to
set the original stylus location or the result is
undefined. Read moreSource§fn multi_cell(
&mut self,
w: Unit,
h: Unit,
text: &str,
border: &str,
align: &str,
fill: bool,
)
fn multi_cell( &mut self, w: Unit, h: Unit, text: &str, border: &str, align: &str, fill: bool, )
Print text with line breaks. The line breaks can be automatic,
by reaching the right border of the cell, or explicit by using
the \n character. As many cells as necessary are output,
one below the other. Read more
Source§fn open_layer_pane(&mut self)
fn open_layer_pane(&mut self)
Advises the document reader to open the layer pane when the
document is initially displayed.
Source§fn output_and_close(&mut self, w: Box<dyn Write>) -> Result<()>
fn output_and_close(&mut self, w: Box<dyn Write>) -> Result<()>
Sends the PDF document to the writer specified by
w. This
method will close the PDF document writer, even if an error is
returned and no document is produced.Source§fn output_file_and_close(&mut self, file: &str) -> Result<()>
fn output_file_and_close(&mut self, file: &str) -> Result<()>
Creates or truncates the file specified by
file and writes
the PDF document to it. This method will close the PDF
document writer, even if an error is returned and no document
is produced.Source§fn output(&mut self, w: Box<dyn Write>) -> Result<()>
fn output(&mut self, w: Box<dyn Write>) -> Result<()>
Output sends the PDF document to the writer specified by
w. No output will take place if an error has occured in the
document generation process. w remains open after this
function returns. After returning, the PDF document writer is
in a closed state and its methods should not be called.Source§fn page_count(&mut self) -> usize
fn page_count(&mut self) -> usize
Returns the number of pages currently in the document. Since
page numbers in FPDF are one-based, the page count is the same
as the page number of the current last page.
Source§fn page_size(&mut self, page_num: usize) -> UnitVec2
fn page_size(&mut self, page_num: usize) -> UnitVec2
Returns the width
x and height y of the specified page in
Unit::Point. If page_num is [0] or otherwise out of
bounds, it returns the default page size.Source§fn polygon(&mut self, points: &[UnitVec2], style: &str)
fn polygon(&mut self, points: &[UnitVec2], style: &str)
Draws a closed figure defined by a series of vertices
specified by points. The last point in the slice will be
implicitly joined with the first to close the polygon. Read more
Source§fn radial_gradient(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
r: f64,
rgb_from: RGB,
rgb_to: RGB,
)
fn radial_gradient( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, x1: f64, y1: f64, x2: f64, y2: f64, r: f64, rgb_from: RGB, rgb_to: RGB, )
Draws a rectangular area with a blending of one color to
another. The rectangle is of width
w and height h. Its
upper left corner is positioned at point (x, y). Read moreSource§fn raw_write_buf(&mut self, r: impl Read)
fn raw_write_buf(&mut self, r: impl Read)
Writes the contents of the specified reader
r directly to
the PDF generation buffer. This is a low-level function that
is not required for normal PDF construction. An understanding
of the PDF specification is needed to use this method
correctly.Source§fn raw_write_str(&mut self, s: &str)
fn raw_write_str(&mut self, s: &str)
Writes the string
s directly to the PDF generation
buffer. This is a low-level function that is not required for
normal PDF construction. An understanding of the PDF
specification is needed to use this method correctly.Source§fn rect(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, style: &str)
fn rect(&mut self, x: Unit, y: Unit, w: Unit, h: Unit, style: &str)
Outputs a rectangle of width
w and height h with the upper
left corner positioned at point (x, y). Read moreSource§fn register_alias(&mut self, alias: &str, replacement: &str)
fn register_alias(&mut self, alias: &str, replacement: &str)
Adds an (
alias, replacement) pair to the document, such
that all occurrences of alias will be replaced with
replacement after writing, but before closing the document. Read moreSource§fn register_image(
&mut self,
file: &str,
options: ImageOptions,
) -> Result<ImageInfo>
fn register_image( &mut self, file: &str, options: ImageOptions, ) -> Result<ImageInfo>
Registers an image, adding it to the PDF file, but not adding
it to the page. Use Pdf::image with the same
file name to
add the image to the page. Read moreSource§fn register_image_reader(
&mut self,
file: &str,
options: ImageOptions,
r: impl Read,
) -> Result<ImageInfo>
fn register_image_reader( &mut self, file: &str, options: ImageOptions, r: impl Read, ) -> Result<ImageInfo>
Registers an image, reading it from
r, adding it to the PDF
file but not adding it to the page. Use Pdf::image with the
same file name to add the image to the page. Read moreSource§fn rounded_rect(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
r: Unit,
corners: &str,
style: &str,
)
fn rounded_rect( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, r: Unit, corners: &str, style: &str, )
Outputs a rectangle of width
w and height h with the upper
left corner positioned at point (x, y). It can be drawn
(border only), filled (with no border), or both. Read moreSource§fn rounded_rect_ext(
&mut self,
x: Unit,
y: Unit,
w: Unit,
h: Unit,
rtl: Unit,
rtr: Unit,
rbr: Unit,
rbl: Unit,
style: &str,
)
fn rounded_rect_ext( &mut self, x: Unit, y: Unit, w: Unit, h: Unit, rtl: Unit, rtr: Unit, rbr: Unit, rbl: Unit, style: &str, )
Behaves the same as Pdf::rounded_rect but supports a
different radius for each corner. A radius of [0] means
squared corner. See Pdf::rounded_rect for more details.
Source§fn set_accept_page_break_fn(&mut self, cb: impl FnMut(&mut Self) -> bool + 'a)
fn set_accept_page_break_fn(&mut self, cb: impl FnMut(&mut Self) -> bool + 'a)
Allows the library to control where page breaks occur. Read more
Source§fn set_alpha(&mut self, alpha: f64, blend_mode: Blend)
fn set_alpha(&mut self, alpha: f64, blend_mode: Blend)
Sets the alpha blending channel. The blending effect applies
to text, drawings and images. Read more
Source§fn set_attachments(&mut self, attachments: Vec<Attachment>)
fn set_attachments(&mut self, attachments: Vec<Attachment>)
Writes attachments as embedded files (document
attachments). These attachments are global, see
Pdf::add_attachment_annotation for a link anchored in a
page. Read more
Defines the author of the document. Read more
Source§fn set_auto_page_break(&mut self, auto: bool, margin: Unit)
fn set_auto_page_break(&mut self, auto: bool, margin: Unit)
Enables or disables the automatic page breaking mode. When
enabling, the second parameter is the distance from the bottom
of the page that defined the triggering limit. By default, the
mode is on and the margin is 2cm.
Source§fn set_catalog_sort(&mut self, flag: bool)
fn set_catalog_sort(&mut self, flag: bool)
Sets a flag that will be used, if true, to consistently order
the document’s internal resource catalogs. This method is
typically only used for testing purposes to facilitate PDF
comparison.
Source§fn set_cell_margin(&mut self, margin: Unit)
fn set_cell_margin(&mut self, margin: Unit)
Sets the cell margin. This is the amount of space before and
after the text within a cell, that is left blank.
Source§fn set_compression(&mut self, compress: bool)
fn set_compression(&mut self, compress: bool)
Activates or deactivates page compression with zlib. When
activated, the internal representation of each page is
compressed, which leads to a compression ratio of about 2
(untested) for the resulting document. Compression is on by
default.
Source§fn set_creation_date(&mut self, datetime: DateTime)
fn set_creation_date(&mut self, datetime: DateTime)
Fixes the document’s internal creation date value. By default,
the time when the document is generated is used for this
value. This method is typically only used for testing purposes
to facilitate PDF comparison. Specify a zero-value time to
revert to the default behavior.
Source§fn set_creator(&mut self, creator: &str, is_utf8: bool)
fn set_creator(&mut self, creator: &str, is_utf8: bool)
Defines the creator of the document. Read more
Source§fn set_dash_pattern(&mut self, dashes: Vec<Unit>, phase: Unit)
fn set_dash_pattern(&mut self, dashes: Vec<Unit>, phase: Unit)
Sets the dash pattern that is used to draw lines. Read more
Source§fn set_display_mode(&mut self, zoom: ZoomMode, layout: Layout)
fn set_display_mode(&mut self, zoom: ZoomMode, layout: Layout)
Sets the advisory display directives for the document
viewer. Pages can be displayed entirely on screen, occupy the
full width of the window, use real size, be scaled by a
specific zoom factor or use viewer default. The page layout
can be specified, so that pages are displayed individually or
in pairs. Read more
Source§fn set_draw_color(&mut self, rgb: RGB)
fn set_draw_color(&mut self, rgb: RGB)
Defines the color used for all drawing operations (lines,
rectangles and cell borders). It is expressed in RGB
components (
0 - 255). The method can be called before the
first page is created. The value is retained from page to
page.Source§fn set_draw_spot_color(&mut self, name: &str, tint: u8)
fn set_draw_spot_color(&mut self, name: &str, tint: u8)
Sets the current draw color to the spot color associated with
name. An error occurs if the name is not associated with a
color. The value for tint ranges from 0 (no intensity) to
100 (full intensity). It is quietly bound to this range.Source§fn set_error(&mut self, err: FpdfError)
fn set_error(&mut self, err: FpdfError)
Sets an error to halt PDF generation. This may facilitate
error handling by application. See also Pdf::ok, Pdf::err
and Pdf::error.
Source§fn set_fill_color(&mut self, rgb: RGB)
fn set_fill_color(&mut self, rgb: RGB)
Defines the color used for all filling operations (filled
rectangles and cell backgrounds). It is expressed in RGB
components (
0 - 255). The method can be called before the
first page is created and the value is retained from page to
page.Source§fn set_fill_spot_color(&mut self, name: &str, tint: u8)
fn set_fill_spot_color(&mut self, name: &str, tint: u8)
Sets the current fill color to the spot color associated with
name. An error occurs if the name is not associated with a
color. The value for tint ranges from 0 (no intensity) to
100 (full intensity). It is quietly bound to this range.Source§fn set_font(&mut self, family: &str, style: &str, size: Unit)
fn set_font(&mut self, family: &str, style: &str, size: Unit)
Sets the fonts used print character strings. It is mandatory
to call this method at least once before printing text or the
resulting document will not be valid. Read more
Source§fn set_font_loader(&mut self, loader: Option<Rc<dyn FontLoader>>)
fn set_font_loader(&mut self, loader: Option<Rc<dyn FontLoader>>)
Sets a loader to read font files (.json and .z) from an
arbitrary source. If a font loader has been specified, it is
used to load the names font resource when Pdf::add_font is
called. If this operation fails, an attempt is made to load
the resources from the configured font directory (see
Pdf::set_font_location).
Source§fn set_font_location(&mut self, font_dir: &str)
fn set_font_location(&mut self, font_dir: &str)
Sets the location in the file stystem of the font and font
definition files.
Source§fn set_font_size(&mut self, size: Unit)
fn set_font_size(&mut self, size: Unit)
Defines the size of the current font. It is usually provided
in Unit::Point.
Source§fn set_font_style(&mut self, style: &str)
fn set_font_style(&mut self, style: &str)
Sets the style of the current font. See also Pdf::set_font.
Sets the function that lets the library render the page
footer. The specified function is automatically called by
Pdf::add_page and Pdf::close and should not be called
directly by the application. Read more
Sets the function thats lets the library render the page
footer. The specified function is automatically called by
Pdf::add_page and Pdf::close and should not be called
directly by the application. Read more
Source§fn set_header_fn(&mut self, cb: impl FnMut(&mut Self) + 'a)
fn set_header_fn(&mut self, cb: impl FnMut(&mut Self) + 'a)
Sets the function that lets the library render the page
header. The specified function is automatically called by
Pdf::add_page and Pdf::close and should not be called
directly by the application. Read more
Source§fn set_header_fn_mode(
&mut self,
cb: impl FnMut(&mut Self) + 'a,
home_mode: bool,
)
fn set_header_fn_mode( &mut self, cb: impl FnMut(&mut Self) + 'a, home_mode: bool, )
Sets the function that lets the library render the page
header. See Pdf::set_header_fn for more details. Read more
Source§fn set_home_xy(&mut self)
fn set_home_xy(&mut self)
Is a convenience method that sets the current position to the
left and top margins.
Source§fn set_javascript(&mut self, script: &str)
fn set_javascript(&mut self, script: &str)
Adds Adobe JavaScript to the document. Read more
Source§fn set_keywords(&mut self, keywords: &str, is_utf8: bool)
fn set_keywords(&mut self, keywords: &str, is_utf8: bool)
Defines the keywords of the document. Read more
Source§fn set_left_margin(&mut self, margin: Unit)
fn set_left_margin(&mut self, margin: Unit)
Defines the left margin. The method can be called before
creating the first page. If the current abscissa gets out of
page, it is brought back to the margin. Read more
Source§fn set_line_cap_style(&mut self, style: &str)
fn set_line_cap_style(&mut self, style: &str)
Defines the line cap style. Read more
Source§fn set_line_join_style(&mut self, style: &str)
fn set_line_join_style(&mut self, style: &str)
Defines the line cap style. Read more
Source§fn set_line_width(&mut self, width: Unit)
fn set_line_width(&mut self, width: Unit)
Defines the line width. By default, the value equals
[Unit::Millimeter(0.2)]. The method can be called before the
first page is created. The value is retained from page to
page.
Source§fn set_link(&mut self, y: Option<Unit>, link: usize, page: Option<usize>)
fn set_link(&mut self, y: Option<Unit>, link: usize, page: Option<usize>)
Defines the page and position a link points to. See
Pdf::add_link.
Source§fn set_margins(&mut self, left: Unit, top: Unit, right: Unit)
fn set_margins(&mut self, left: Unit, top: Unit, right: Unit)
Defines the left, top and right margins. By default, they
equal [Unit::Centimeter(1.0)]. Call this method to change
them. If the value of the right margin is less than [0.0], it
is set to the same as the left margin.
Source§fn set_modification_date(&mut self, tm: DateTime)
fn set_modification_date(&mut self, tm: DateTime)
Fixes the document’s internal modification date value. See
Pdf::set_creation_date for more details. Read more
Source§fn set_page_box_rec(&mut self, t: &str, pb: PageBox)
fn set_page_box_rec(&mut self, t: &str, pb: PageBox)
Sets the page box for the current page, and any following
pages. Read more
Source§fn set_page_box(&mut self, x: Unit, y: Unit, width: Unit, height: Unit, t: &str)
fn set_page_box(&mut self, x: Unit, y: Unit, width: Unit, height: Unit, t: &str)
Sets the page box for the current page, and any following
pages. Read more
Source§fn set_page(&mut self, page_num: usize)
fn set_page(&mut self, page_num: usize)
Sets the current page to that of a valid page in the PDF
document. Read more
Source§fn set_producer(&mut self, producer: &str, is_utf8: bool)
fn set_producer(&mut self, producer: &str, is_utf8: bool)
Defines the producer of the document. Read more
Source§fn set_protection(
&mut self,
action_flag: u8,
user_password: &str,
owner_password: &str,
)
fn set_protection( &mut self, action_flag: u8, user_password: &str, owner_password: &str, )
Applies certain constrains on the finished PDF document. Read more
Source§fn set_right_margin(&mut self, margin: Unit)
fn set_right_margin(&mut self, margin: Unit)
Defines the right margin. The method can be called before
creating the first page.
Source§fn set_subject(&mut self, subject: &str, is_utf8: bool)
fn set_subject(&mut self, subject: &str, is_utf8: bool)
Defines the subject of the document. Read more
Source§fn set_text_color(&mut self, rgb: RGB)
fn set_text_color(&mut self, rgb: RGB)
Defines the color used for text. It is expressed in RGB
components (
0 - 255). The method can be called before the
first page is created. The value is retained from page to
page. Read moreSource§fn set_text_spot_color(&mut self, name: &str, tint: u8)
fn set_text_spot_color(&mut self, name: &str, tint: u8)
Sets the current text color to the spot color associated with
name. An error occurs if the name is not associated with a
color. The value for tint ranges from 0 (no intensity) to
100 (full intensity). It is quietly bound to this range.Source§fn set_title(&mut self, title: &str, is_utf8: bool)
fn set_title(&mut self, title: &str, is_utf8: bool)
Defines the title of the document. Read more
Source§fn set_top_margin(&mut self, margin: Unit)
fn set_top_margin(&mut self, margin: Unit)
Defines the top margin. The method can be called before
creating the first page.
Source§fn set_underline_thickness(&mut self, thickness: f64)
fn set_underline_thickness(&mut self, thickness: f64)
Accepts a multiplier for adjusting the text underline
thickness, defaulting to [1.0]. Read more
Source§fn set_word_spacing(&mut self, space: Unit)
fn set_word_spacing(&mut self, space: Unit)
Sets spacing between words of following text. See
Pdf::write_aligned example for a demonstration of its use.
Source§fn set_text_rendering_mode(&mut self, mode: u8)
fn set_text_rendering_mode(&mut self, mode: u8)
Sets the rendering mode of following text.
The mode can be as follows: Read more
Source§fn set_xmp_metadata(&mut self, xmp_stream: Vec<u8>)
fn set_xmp_metadata(&mut self, xmp_stream: Vec<u8>)
Defines the XMP metadata that will be embedded with the
document.
Source§fn set_x(&mut self, x: Unit)
fn set_x(&mut self, x: Unit)
Defines the abscissa of the current position. If the passed
value is negative, it is relative to the right of the page.
Source§fn set_xy(&mut self, x: Unit, y: Unit)
fn set_xy(&mut self, x: Unit, y: Unit)
Defined the abscissa and ordinate of the current position. If
the passed values are negative, they are relative respectively
to the right and bottom of the page.
Source§fn set_y(&mut self, y: Unit)
fn set_y(&mut self, y: Unit)
Moves the current abscissa back to the left margin and sets
the ordinate. If the passed value is negative, it is relative
to the bottom of the page.
Source§fn split_lines(&mut self, text: &[u8], width: Unit) -> Vec<Vec<u8>>
fn split_lines(&mut self, text: &[u8], width: Unit) -> Vec<Vec<u8>>
Splits text into several lines using the current font. Each
line has its length limited to a maximum
width. This
function can be used to determine the total height of wrapped
text for vertical placement purposes. Read moreSource§fn split_text(&mut self, text: &str, width: Unit) -> Vec<String>
fn split_text(&mut self, text: &str, width: Unit) -> Vec<String>
Splits UTF-8 encoded text into several lines using the current
font. Each line has its length limited to a maximum
width. This function can be used to determine the total
height of wrapped text for vertical placement purposes.Source§fn svg_basic_write(&mut self, sb: &SVGBasic, scale: Unit)
fn svg_basic_write(&mut self, sb: &SVGBasic, scale: Unit)
Renders the paths encoded in the basic SVH image specified by
sb. Read moreSource§fn sub_write(
&mut self,
height: Unit,
text: &str,
sub_font_size: Unit,
sub_offset: Unit,
link: usize,
link_str: &str,
)
fn sub_write( &mut self, height: Unit, text: &str, sub_font_size: Unit, sub_offset: Unit, link: usize, link_str: &str, )
Prints text from the current position in the same way as
Pdf::write. Read more
Source§fn text(&mut self, x: Unit, y: Unit, text: &str)
fn text(&mut self, x: Unit, y: Unit, text: &str)
Prints a character string. The origin (
x, y) is on the
left of the first character at the baseline. This method
permits a string to be placed precisely on the page, but it is
usually easier to use Pdf::cell, Pdf::multi_cell or
Pdf::write which are the standard methods to print text.Source§fn transform_begin(&mut self)
fn transform_begin(&mut self)
Sets up a transformation context for subsequent text, drawings
and images. The typical usage is to immediately follow a call
to this method with a call to one or more of the
transformation methods, such as Pdf::transform_scale,
Pdf::transform_skew, etc. This is followed by text, drawing
or image output and finally a call to
Pdf::transform_end. All transformation contexts must be
properly ended prior to outputting the document. Read more
Source§fn transform_end(&mut self)
fn transform_end(&mut self)
Applies a transformation that was begun with a call to
Pdf::transform_begin. Read more
Source§fn transform_mirror_horizontal(&mut self, x: Unit)
fn transform_mirror_horizontal(&mut self, x: Unit)
Horizontally mirrors the following text, drawings and images. Read more
Source§fn transform_mirror_line(&mut self, x: Unit, y: Unit, angle: f64)
fn transform_mirror_line(&mut self, x: Unit, y: Unit, angle: f64)
Symmetrically mirrors the following text, drawings and images
on the line defined by
angle and the point (x, y). Read moreSource§fn transform_mirror_point(&mut self, x: Unit, y: Unit)
fn transform_mirror_point(&mut self, x: Unit, y: Unit)
Symmetrically mirrors the following text, drawings and images
on the point specified by (
x, y). Read moreSource§fn transform_mirror_vertical(&mut self, y: Unit)
fn transform_mirror_vertical(&mut self, y: Unit)
Vertically mirrors the following text, drawings and
images.
y is the axis of reflection. Read moreSource§fn transform_scale(
&mut self,
x: Unit,
y: Unit,
scale_width: f64,
scale_height: f64,
)
fn transform_scale( &mut self, x: Unit, y: Unit, scale_width: f64, scale_height: f64, )
Generally scales the following text, drawings and images. Read more
Source§fn transform_scale_x(&mut self, x: Unit, y: Unit, scale_width: f64)
fn transform_scale_x(&mut self, x: Unit, y: Unit, scale_width: f64)
Scales the width of the following text, drawings and images. Read more
Source§fn transform_scale_xy(&mut self, x: Unit, y: Unit, s: f64)
fn transform_scale_xy(&mut self, x: Unit, y: Unit, s: f64)
Uniformly scales the width and height of the following text,
drawings and images. Read more
Source§fn transform_scale_y(&mut self, x: Unit, y: Unit, scale_height: f64)
fn transform_scale_y(&mut self, x: Unit, y: Unit, scale_height: f64)
Scales the height of the following text, drawings and images. Read more
Source§fn transform_skew(&mut self, x: Unit, y: Unit, angle_x: f64, angle_y: f64)
fn transform_skew(&mut self, x: Unit, y: Unit, angle_x: f64, angle_y: f64)
Generally skews the following text, drawings and images
keeping the point (
x, y) stationary. Read moreSource§fn transform_skew_x(&mut self, x: Unit, y: Unit, angle_x: f64)
fn transform_skew_x(&mut self, x: Unit, y: Unit, angle_x: f64)
Horizontally skews the following text, drawings and images
keeping the point (
x, y) stationary. Read moreSource§fn transform_skew_y(&mut self, x: Unit, y: Unit, angle_y: f64)
fn transform_skew_y(&mut self, x: Unit, y: Unit, angle_y: f64)
Vertically skews the following text, drawings and images
keeping the point (
x, y) stationary. Read moreSource§fn transform(&mut self, tm: &TransformMatrix)
fn transform(&mut self, tm: &TransformMatrix)
Generally transforms the following text, drawings and images
according to the specified matrix
tm. It is typically easier
to use the various methods, such as Pdf::transform_rotate
and Pdf::transform_mirror_vertical instead.Source§fn transform_translate(&mut self, tx: Unit, ty: Unit)
fn transform_translate(&mut self, tx: Unit, ty: Unit)
Moves the following text, drawings and images horizontally and
vertically by the amounts specified by
tx and ty. Read moreSource§fn transform_translate_x(&mut self, tx: Unit)
fn transform_translate_x(&mut self, tx: Unit)
Moves the following text, drawings and images horizontally by
the amount specified by
tx. Read moreSource§fn transform_translate_y(&mut self, ty: Unit)
fn transform_translate_y(&mut self, ty: Unit)
Moves the following text, drawings and images vertically by
the amount specified by
ty. Read moreSource§fn unicode_translator_from_descriptor(
&mut self,
cp: &str,
) -> Rc<dyn Fn(String) -> String>
fn unicode_translator_from_descriptor( &mut self, cp: &str, ) -> Rc<dyn Fn(String) -> String>
Returns a function, that can be used to translate, where
possible, UTF-8 string to a form that is compatible with the
specified code page. See [Pdf::unicode_translator] for more
details. Read more
Source§fn use_imported_template(
&mut self,
t: &str,
scale_x: Unit,
scale_y: Unit,
tx: Unit,
ty: Unit,
)
fn use_imported_template( &mut self, t: &str, scale_x: Unit, scale_y: Unit, tx: Unit, ty: Unit, )
Uses imported template. It draws imported PDF page ontp page.
Source§fn use_template_scaled(
&mut self,
t: Rc<dyn Template>,
corner: Vec2,
size: UnitVec2,
)
fn use_template_scaled( &mut self, t: Rc<dyn Template>, corner: Vec2, size: UnitVec2, )
Adds a template to the current page or another template, using
the given page coordinates.
Source§fn use_template(&mut self, t: Rc<dyn Template>)
fn use_template(&mut self, t: Rc<dyn Template>)
Adds a template to the current page or another template, using
the size and position at which it was originally written.
Source§fn write_aligned(
&mut self,
width: Unit,
line_height: Unit,
text: &str,
align: &str,
)
fn write_aligned( &mut self, width: Unit, line_height: Unit, text: &str, align: &str, )
Is an implementation of Pdf::write that makes it possible to
align text. Read more
Source§fn write(&mut self, h: Unit, text: &str)
fn write(&mut self, h: Unit, text: &str)
Prints text from the current position. When the right margin
is reached (or the ‘\n’ character is met), a line break occurs
and text continues from the left margin. Upon method exit, the
current position is left just at the end of the text.
Source§fn write_basic_html(&mut self, line_height: Unit, html: &str)
fn write_basic_html(&mut self, line_height: Unit, html: &str)
Write basic HTML into the PDF file. Read more
Auto Trait Implementations§
impl<'a> Freeze for Fpdf<'a>
impl<'a> !RefUnwindSafe for Fpdf<'a>
impl<'a> !Send for Fpdf<'a>
impl<'a> !Sync for Fpdf<'a>
impl<'a> Unpin for Fpdf<'a>
impl<'a> !UnwindSafe for Fpdf<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more