pub struct Content { /* private fields */ }Expand description
A builder for a content stream.
Implementations§
Source§impl Content
Core methods.
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.
Sourcepub fn op<'a>(&'a mut self, operator: &'a str) -> Operation<'a>
pub fn op<'a>(&'a mut self, operator: &'a str) -> Operation<'a>
Start writing an arbitrary operation.
Sourcepub fn finish(self) -> Buf
pub fn finish(self) -> Buf
Return the buffer of the content stream.
The buffer is essentially a thin wrapper around two objects:
- A
Limitsobject, which can optionally be used to keep track of data such as the largest used integer or the longest string used in the content streams, which is useful information for some export modes. - The actual underlying data of the content stream, which can be written to a chunk (and optionally apply a filter before doing so).
Source§impl Content
General graphics state.
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
Special graphics state.
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
Path construction.
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
Path painting.
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
Clipping paths.
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
Text objects.
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
Text state.
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
Text positioning.
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
Text showing.
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
Type 3 fonts.
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.
wxdefines the glyph’s widthwyis 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.
wxdefines the glyph’s widthwyis set to 0.0 automaticallyll_xandll_ydefine the lower-left corner of the glyph bounding boxur_xandur_ydefine the upper-right corner of the glyph bounding box
Source§impl Content
Color.
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
Marked 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
Compatibility.
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.