pub struct Content { /* private fields */ }
Expand description
A builder for a content stream.
Implementations§
source§impl Content
impl Content
Core methods.
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new content stream with the default buffer capacity (currently 1 KB).
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new content stream with the specified initial buffer capacity.
source§impl Content
impl Content
General graphics state.
sourcepub fn set_line_width(&mut self, width: f32) -> &mut Self
pub fn set_line_width(&mut self, width: f32) -> &mut Self
w
: Set the stroke line width.
Panics if width
is negative.
sourcepub fn set_line_cap(&mut self, cap: LineCapStyle) -> &mut Self
pub fn set_line_cap(&mut self, cap: LineCapStyle) -> &mut Self
J
: Set the line cap style.
sourcepub fn set_line_join(&mut self, join: LineJoinStyle) -> &mut Self
pub fn set_line_join(&mut self, join: LineJoinStyle) -> &mut Self
j
: Set the line join style.
sourcepub fn set_miter_limit(&mut self, limit: f32) -> &mut Self
pub fn set_miter_limit(&mut self, limit: f32) -> &mut Self
M
: Set the miter limit.
sourcepub fn set_dash_pattern(
&mut self,
array: impl IntoIterator<Item = f32>,
phase: f32,
) -> &mut Self
pub fn set_dash_pattern( &mut self, array: impl IntoIterator<Item = f32>, phase: f32, ) -> &mut Self
d
: Set the line dash pattern.
sourcepub fn set_rendering_intent(&mut self, intent: RenderingIntent) -> &mut Self
pub fn set_rendering_intent(&mut self, intent: RenderingIntent) -> &mut Self
ri
: Set the color rendering intent to the parameter. PDF 1.1+.
sourcepub fn set_flatness(&mut self, tolerance: i32) -> &mut Self
pub fn set_flatness(&mut self, tolerance: i32) -> &mut Self
i
: Set the flatness tolerance in device pixels.
Panics if tolerance
is negative or larger than 100.
sourcepub fn set_parameters(&mut self, dict: Name<'_>) -> &mut Self
pub fn set_parameters(&mut self, dict: Name<'_>) -> &mut Self
gs
: Set the parameters from an ExtGState
dictionary. PDF 1.2+.
source§impl Content
impl Content
Special graphics state.
sourcepub fn save_state(&mut self) -> &mut Self
pub fn save_state(&mut self) -> &mut Self
q
: Save the graphics state on the stack.
sourcepub fn restore_state(&mut self) -> &mut Self
pub fn restore_state(&mut self) -> &mut Self
Q
: Restore the graphics state from the stack.
sourcepub fn state_nesting_depth(&self) -> usize
pub fn state_nesting_depth(&self) -> usize
The current q
nesting depth.
source§impl Content
impl Content
Path construction.
sourcepub fn cubic_to(
&mut self,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
x3: f32,
y3: f32,
) -> &mut Self
pub fn cubic_to( &mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32, ) -> &mut Self
c
: Append a cubic Bézier segment to (x3, y3) with (x1, y1), (x2, y2)
as control points.
sourcepub fn cubic_to_initial(
&mut self,
x2: f32,
y2: f32,
x3: f32,
y3: f32,
) -> &mut Self
pub fn cubic_to_initial( &mut self, x2: f32, y2: f32, x3: f32, y3: f32, ) -> &mut Self
v
: Append a cubic Bézier segment to (x3, y3) with (x2, y2) as control
point.
sourcepub fn cubic_to_final(
&mut self,
x1: f32,
y1: f32,
x3: f32,
y3: f32,
) -> &mut Self
pub fn cubic_to_final( &mut self, x1: f32, y1: f32, x3: f32, y3: f32, ) -> &mut Self
y
: Append a cubic Bézier segment to (x3, y3) with (x1, y1) as control
point.
sourcepub fn close_path(&mut self) -> &mut Self
pub fn close_path(&mut self) -> &mut Self
h
: Close the current subpath with a straight line.
source§impl Content
impl Content
Path painting.
sourcepub fn close_and_stroke(&mut self) -> &mut Self
pub fn close_and_stroke(&mut self) -> &mut Self
s
: Close the current path and then stroke it.
sourcepub fn fill_nonzero(&mut self) -> &mut Self
pub fn fill_nonzero(&mut self) -> &mut Self
f
: Fill the current path using the nonzero winding number rule.
sourcepub fn fill_even_odd(&mut self) -> &mut Self
pub fn fill_even_odd(&mut self) -> &mut Self
f*
: Fill the current path using the even-odd rule.
sourcepub fn fill_nonzero_and_stroke(&mut self) -> &mut Self
pub fn fill_nonzero_and_stroke(&mut self) -> &mut Self
B
: Fill the current path using the nonzero winding number rule and
then stroke it.
sourcepub fn fill_even_odd_and_stroke(&mut self) -> &mut Self
pub fn fill_even_odd_and_stroke(&mut self) -> &mut Self
B*
: Fill the current path using the even-odd rule and then stroke it.
sourcepub fn close_fill_nonzero_and_stroke(&mut self) -> &mut Self
pub fn close_fill_nonzero_and_stroke(&mut self) -> &mut Self
b
: Close the current path, fill it using the nonzero winding number
rule and then stroke it.
sourcepub fn close_fill_even_odd_and_stroke(&mut self) -> &mut Self
pub fn close_fill_even_odd_and_stroke(&mut self) -> &mut Self
b*
: Close the current path, fill it using the even-odd rule and then
stroke it.
source§impl Content
impl Content
Clipping paths.
sourcepub fn clip_nonzero(&mut self) -> &mut Self
pub fn clip_nonzero(&mut self) -> &mut Self
W
: Intersect the current clipping path with the current path using the
nonzero winding number rule.
sourcepub fn clip_even_odd(&mut self) -> &mut Self
pub fn clip_even_odd(&mut self) -> &mut Self
W*
: Intersect the current clipping path with the current path using
the even-odd rule.
source§impl Content
impl Content
Text objects.
sourcepub fn begin_text(&mut self) -> &mut Self
pub fn begin_text(&mut self) -> &mut Self
BT
: Begin a text object.
source§impl Content
impl Content
Text state.
sourcepub fn set_char_spacing(&mut self, spacing: f32) -> &mut Self
pub fn set_char_spacing(&mut self, spacing: f32) -> &mut Self
Tc
: Set the character spacing.
sourcepub fn set_word_spacing(&mut self, spacing: f32) -> &mut Self
pub fn set_word_spacing(&mut self, spacing: f32) -> &mut Self
Tw
: Set the word spacing.
sourcepub fn set_horizontal_scaling(&mut self, scaling: f32) -> &mut Self
pub fn set_horizontal_scaling(&mut self, scaling: f32) -> &mut Self
Tz
: Set the horizontal scaling.
sourcepub fn set_leading(&mut self, leading: f32) -> &mut Self
pub fn set_leading(&mut self, leading: f32) -> &mut Self
TL
: Set the leading.
sourcepub fn set_text_rendering_mode(&mut self, mode: TextRenderingMode) -> &mut Self
pub fn set_text_rendering_mode(&mut self, mode: TextRenderingMode) -> &mut Self
Tr
: Set the text rendering mode.
source§impl Content
impl Content
Text positioning.
sourcepub fn next_line(&mut self, x: f32, y: f32) -> &mut Self
pub fn next_line(&mut self, x: f32, y: f32) -> &mut Self
Td
: Move to the start of the next line.
sourcepub fn next_line_and_set_leading(&mut self, x: f32, y: f32) -> &mut Self
pub fn next_line_and_set_leading(&mut self, x: f32, y: f32) -> &mut Self
TD
: Move to the start of the next line and set the text state’s
leading parameter to -y
.
sourcepub fn set_text_matrix(&mut self, matrix: [f32; 6]) -> &mut Self
pub fn set_text_matrix(&mut self, matrix: [f32; 6]) -> &mut Self
Tm
: Set the text matrix.
sourcepub fn next_line_using_leading(&mut self) -> &mut Self
pub fn next_line_using_leading(&mut self) -> &mut Self
T*
: Move to the start of the next line, determining the vertical offset
through the text state’s leading parameter.
source§impl Content
impl Content
Text showing.
sourcepub fn show(&mut self, text: Str<'_>) -> &mut Self
pub fn show(&mut self, text: Str<'_>) -> &mut Self
Tj
: Show text.
The encoding of the text depends on the font.
sourcepub fn next_line_show(&mut self, text: Str<'_>) -> &mut Self
pub fn next_line_show(&mut self, text: Str<'_>) -> &mut Self
'
: Move to the next line and show text.
sourcepub fn next_line_show_and_set_word_and_char_spacing(
&mut self,
word_spacing: f32,
char_spacing: f32,
text: Str<'_>,
) -> &mut Self
pub fn next_line_show_and_set_word_and_char_spacing( &mut self, word_spacing: f32, char_spacing: f32, text: Str<'_>, ) -> &mut Self
"
: Move to the next line, show text and set the text state’s word and
character spacing.
sourcepub fn show_positioned(&mut self) -> ShowPositioned<'_>
pub fn show_positioned(&mut self) -> ShowPositioned<'_>
TJ
: Start showing text with individual glyph positioning.
source§impl Content
impl Content
Type 3 fonts.
These operators are only allowed in Type 3 CharProcs.
sourcepub fn start_color_glyph(&mut self, wx: f32) -> &mut Self
pub fn start_color_glyph(&mut self, wx: f32) -> &mut Self
d0
: Starts a Type 3 glyph that contains color information.
wx
defines the glyph’s widthwy
is set to 0.0 automatically
sourcepub fn start_shape_glyph(
&mut self,
wx: f32,
ll_x: f32,
ll_y: f32,
ur_x: f32,
ur_y: f32,
) -> &mut Self
pub fn start_shape_glyph( &mut self, wx: f32, ll_x: f32, ll_y: f32, ur_x: f32, ur_y: f32, ) -> &mut Self
d1
: Starts a Type 3 glyph that contains only shape information.
wx
defines the glyph’s widthwy
is set to 0.0 automaticallyll_x
andll_y
define the lower-left corner of the glyph bounding boxur_x
andur_y
define the upper-right corner of the glyph bounding box
source§impl Content
impl Content
Color.
sourcepub fn set_stroke_color_space<'a>(
&mut self,
space: impl Into<ColorSpaceOperand<'a>>,
) -> &mut Self
pub fn set_stroke_color_space<'a>( &mut self, space: impl Into<ColorSpaceOperand<'a>>, ) -> &mut Self
CS
: Set the stroke color space to the parameter. PDF 1.1+.
The parameter must be the name of a parameter-less color space or of a color space dictionary within the current resource dictionary.
sourcepub fn set_fill_color_space<'a>(
&mut self,
space: impl Into<ColorSpaceOperand<'a>>,
) -> &mut Self
pub fn set_fill_color_space<'a>( &mut self, space: impl Into<ColorSpaceOperand<'a>>, ) -> &mut Self
cs
: Set the fill color space to the parameter. PDF 1.1+.
The parameter must be the name of a parameter-less color space or of a color space dictionary within the current resource dictionary.
sourcepub fn set_stroke_color(
&mut self,
color: impl IntoIterator<Item = f32>,
) -> &mut Self
pub fn set_stroke_color( &mut self, color: impl IntoIterator<Item = f32>, ) -> &mut Self
SCN
: Set the stroke color to the parameter within the current color
space. PDF 1.2+.
sourcepub fn set_stroke_pattern(
&mut self,
tint: impl IntoIterator<Item = f32>,
name: Name<'_>,
) -> &mut Self
pub fn set_stroke_pattern( &mut self, tint: impl IntoIterator<Item = f32>, name: Name<'_>, ) -> &mut Self
SCN
: Set the stroke pattern. PDF 1.2+.
The name
parameter is the name of a pattern. If this is an uncolored
pattern, a tint color in the current Pattern
base color space must be
given, otherwise, the color
iterator shall remain empty.
sourcepub fn set_fill_color(
&mut self,
color: impl IntoIterator<Item = f32>,
) -> &mut Self
pub fn set_fill_color( &mut self, color: impl IntoIterator<Item = f32>, ) -> &mut Self
scn
: Set the fill color to the parameter within the current color
space. PDF 1.2+.
sourcepub fn set_fill_pattern(
&mut self,
tint: impl IntoIterator<Item = f32>,
name: Name<'_>,
) -> &mut Self
pub fn set_fill_pattern( &mut self, tint: impl IntoIterator<Item = f32>, name: Name<'_>, ) -> &mut Self
scn
: Set the fill pattern. PDF 1.2+.
The name
parameter is the name of a pattern. If this is an uncolored
pattern, a tint color in the current Pattern
base color space must be
given, otherwise, the color
iterator shall remain empty.
sourcepub fn set_stroke_gray(&mut self, gray: f32) -> &mut Self
pub fn set_stroke_gray(&mut self, gray: f32) -> &mut Self
G
: Set the stroke color to the parameter and the color space to
DeviceGray
.
sourcepub fn set_fill_gray(&mut self, gray: f32) -> &mut Self
pub fn set_fill_gray(&mut self, gray: f32) -> &mut Self
g
: Set the fill color to the parameter and the color space to
DeviceGray
.
sourcepub fn set_stroke_rgb(&mut self, r: f32, g: f32, b: f32) -> &mut Self
pub fn set_stroke_rgb(&mut self, r: f32, g: f32, b: f32) -> &mut Self
RG
: Set the stroke color to the parameter and the color space to
DeviceRGB
.
sourcepub fn set_fill_rgb(&mut self, r: f32, g: f32, b: f32) -> &mut Self
pub fn set_fill_rgb(&mut self, r: f32, g: f32, b: f32) -> &mut Self
rg
: Set the fill color to the parameter and the color space to
DeviceRGB
.
source§impl Content
impl Content
Marked Content.
sourcepub fn marked_content_point(&mut self, tag: Name<'_>) -> &mut Self
pub fn marked_content_point(&mut self, tag: Name<'_>) -> &mut Self
MP
: Write a marked-content point. PDF 1.2+.
sourcepub fn marked_content_point_with_properties(
&mut self,
tag: Name<'_>,
) -> MarkContent<'_>
pub fn marked_content_point_with_properties( &mut self, tag: Name<'_>, ) -> MarkContent<'_>
DP
: Start writing a marked-content point operation. PDF 1.2+.
sourcepub fn begin_marked_content(&mut self, tag: Name<'_>) -> &mut Self
pub fn begin_marked_content(&mut self, tag: Name<'_>) -> &mut Self
BMC
: Begin a marked-content sequence. PDF 1.2+.
sourcepub fn begin_marked_content_with_properties(
&mut self,
tag: Name<'_>,
) -> MarkContent<'_>
pub fn begin_marked_content_with_properties( &mut self, tag: Name<'_>, ) -> MarkContent<'_>
BDC
: Start writing a “begin marked content” operation. PDF 1.2+.
sourcepub fn end_marked_content(&mut self) -> &mut Self
pub fn end_marked_content(&mut self) -> &mut Self
EMC
: End a marked-content sequence. PDF 1.2+.
source§impl Content
impl Content
Compatibility.
sourcepub fn begin_compat(&mut self) -> &mut Self
pub fn begin_compat(&mut self) -> &mut Self
BX
: Begin a compatibility section.
sourcepub fn end_compat(&mut self) -> &mut Self
pub fn end_compat(&mut self) -> &mut Self
EX
: End a compatibility section.