pub struct TextParagraphProperties {Show 14 fields
pub alignment: Option<TextAlign>,
pub margin_left_emu: Option<i64>,
pub margin_right_emu: Option<i64>,
pub indent_emu: Option<i64>,
pub level: Option<u8>,
pub tab_stops: Vec<TabStop>,
pub line_spacing: Option<TextSpacing>,
pub space_before: Option<TextSpacing>,
pub space_after: Option<TextSpacing>,
pub bullet_color: Option<BulletColor>,
pub bullet_size: Option<BulletSize>,
pub bullet_font: Option<BulletFont>,
pub bullet: Option<BulletKind>,
pub default_run_properties: Option<Box<TextRunProperties>>,
}Expand description
<a:pPr>’s attributes (CT_TextParagraphProperties) — alignment, margins/indent, tab stops
(tabLst), paragraph spacing, indent/outline level, default run formatting, and bullets.
Not modeled: <a:lstStyle> (a text body’s own per-level default paragraph styles, distinct from
any individual paragraph’s own pPr modeled here — see TextBody’s doc comment).
Fields§
§alignment: Option<TextAlign>algn.
margin_left_emu: Option<i64>marL, in EMUs.
margin_right_emu: Option<i64>marR, in EMUs.
indent_emu: Option<i64>indent (first-line indent, can be negative for a hanging indent), in EMUs.
level: Option<u8>lvl (ST_TextIndentLevelType, 0.=8) — this paragraph’s indent/outline level, the
mechanism real PowerPoint uses for multi-level bulleted/numbered lists (each level typically
resolves its own bullet/indent/font size from the placeholder’s <a:lstStyle> when not
overridden directly on the paragraph, as here). None omits the attribute, equivalent to
level 0. Grounded against a real fixture.
tab_stops: Vec<TabStop><a:tabLst><a:tab pos=".." algn=".."/>*</a:tabLst> — this paragraph’s own explicit tab
stops, overriding whatever default tab spacing the host application would otherwise use. An
empty Vec (the default) omits <a:tabLst> entirely, same “only write what was actually
set” convention as every other optional child in this crate.
line_spacing: Option<TextSpacing><a:lnSpc> — line spacing. None inherits the host application’s default.
space_before: Option<TextSpacing><a:spcBef> — space before the paragraph.
space_after: Option<TextSpacing><a:spcAft> — space after the paragraph.
bullet_color: Option<BulletColor><a:buClrTx/>/<a:buClr> — this paragraph’s bullet color. None omits the element
entirely (the bullet’s color follows whatever the list style/master otherwise resolves,
PowerPoint’s actual default), distinct from Some(BulletColor::FollowText) (<a:buClrTx/>,
explicitly “follow the text run’s own color”).
bullet_size: Option<BulletSize><a:buSzTx/>/<a:buSzPct>/<a:buSzPts> — this paragraph’s bullet size. Same
None-omits-the-element posture as bullet_color.
bullet_font: Option<BulletFont><a:buFontTx/>/<a:buFont typeface="."> — this paragraph’s bullet font. Same
None-omits-the-element posture as bullet_color. Only typeface is modeled (not
panose/ pitchFamily/charset, all optional cosmetic hints).
bullet: Option<BulletKind><a:buNone/>/<a:buChar char=".">/<a:buAutoNum type="."> — this paragraph’s own
bullet/numbering marker. None omits the element entirely (inherits from the list
style/master, PowerPoint’s actual default — usually a bullet for body text). Grounded
against real fixtures covering both buChar and buAutoNum.
default_run_properties: Option<Box<TextRunProperties>><a:defRPr> — this paragraph’s own default run formatting, used by any run that doesn’t set
the matching property itself, and by an empty paragraph’s own end-of-paragraph mark. None
omits the element entirely. Reuses TextRunProperties verbatim, the same vocabulary an
individual run’s own <a:rPr> uses.
Implementations§
Source§impl TextParagraphProperties
impl TextParagraphProperties
Sourcepub fn new() -> TextParagraphProperties
pub fn new() -> TextParagraphProperties
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}pub fn with_alignment(self, alignment: TextAlign) -> TextParagraphProperties
pub fn with_margins_emu(self, left: i64, right: i64) -> TextParagraphProperties
Sourcepub fn with_indent_emu(self, indent: i64) -> TextParagraphProperties
pub fn with_indent_emu(self, indent: i64) -> TextParagraphProperties
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}Sourcepub fn with_level(self, level: u8) -> TextParagraphProperties
pub fn with_level(self, level: u8) -> TextParagraphProperties
Sets the indent/outline level (0.=8).
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}Sourcepub fn with_tab_stop(self, tab_stop: TabStop) -> TextParagraphProperties
pub fn with_tab_stop(self, tab_stop: TabStop) -> TextParagraphProperties
Appends one explicit tab stop.
Sourcepub fn with_line_spacing(self, spacing: TextSpacing) -> TextParagraphProperties
pub fn with_line_spacing(self, spacing: TextSpacing) -> TextParagraphProperties
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}Sourcepub fn with_space_before(self, spacing: TextSpacing) -> TextParagraphProperties
pub fn with_space_before(self, spacing: TextSpacing) -> TextParagraphProperties
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}pub fn with_space_after(self, spacing: TextSpacing) -> TextParagraphProperties
pub fn with_bullet_color(self, color: BulletColor) -> TextParagraphProperties
pub fn with_bullet_size(self, size: BulletSize) -> TextParagraphProperties
pub fn with_bullet_font(self, font: BulletFont) -> TextParagraphProperties
Sourcepub fn with_bullet(self, bullet: BulletKind) -> TextParagraphProperties
pub fn with_bullet(self, bullet: BulletKind) -> TextParagraphProperties
Examples found in repository?
19fn main() -> office_toolkit::Result<()> {
20 let path = output_path("pptx_text_formatting.pptx");
21
22 let spacing_shape = AutoShape::new(2, "Spacing")
23 .with_properties(
24 ShapeProperties::new().with_transform(
25 Transform2D::new()
26 .with_offset(838_200, 838_200)
27 .with_extent(6_000_000, 1_500_000),
28 ),
29 )
30 .with_text_body(
31 TextBody::new().with_paragraph(
32 TextParagraph::new()
33 .with_properties(
34 TextParagraphProperties::new()
35 .with_line_spacing(TextSpacing::Percent(150_000))
36 .with_space_before(TextSpacing::Points(1200))
37 .with_indent_emu(457_200)
38 .with_level(1),
39 )
40 .with_run(TextRun::text(
41 "Indented, 150% line spacing, 12pt space before.",
42 )),
43 ),
44 );
45
46 let bullets_shape = AutoShape::new(2, "Bullets")
47 .with_properties(
48 ShapeProperties::new().with_transform(
49 Transform2D::new()
50 .with_offset(838_200, 838_200)
51 .with_extent(6_000_000, 1_800_000),
52 ),
53 )
54 .with_text_body(
55 TextBody::new()
56 .with_paragraph(
57 TextParagraph::new()
58 .with_properties(
59 TextParagraphProperties::new()
60 .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61 )
62 .with_run(TextRun::text("Bulleted item")),
63 )
64 .with_paragraph(
65 TextParagraph::new()
66 .with_properties(TextParagraphProperties::new().with_bullet(
67 BulletKind::AutoNumber {
68 scheme: "arabicPeriod".to_string(),
69 start_at: None,
70 },
71 ))
72 .with_run(TextRun::text("Auto-numbered item")),
73 ),
74 );
75
76 let autofit_shape = AutoShape::new(2, "Autofit")
77 .with_text_box(true)
78 .with_properties(
79 ShapeProperties::new().with_transform(
80 Transform2D::new()
81 .with_offset(838_200, 838_200)
82 .with_extent(4_000_000, 1_000_000),
83 ),
84 )
85 .with_text_body(
86 TextBody::new()
87 .with_properties(
88 TextBodyProperties::new()
89 .with_autofit(TextAutofit::Shape)
90 .with_anchor(TextAnchor::Center)
91 .with_anchor_center(true),
92 )
93 .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94 "This shape resizes to fit its text, centered both ways.",
95 ))),
96 );
97
98 let casing_shape = AutoShape::new(2, "Casing")
99 .with_properties(
100 ShapeProperties::new().with_transform(
101 Transform2D::new()
102 .with_offset(838_200, 838_200)
103 .with_extent(6_000_000, 1_500_000),
104 ),
105 )
106 .with_text_body(
107 TextBody::new().with_paragraph(
108 TextParagraph::new()
109 .with_run(TextRun::text_with_properties(
110 "rendered in all caps, ",
111 TextRunProperties::new().with_text_caps(TextCaps::All),
112 ))
113 .with_run(TextRun::text_with_properties(
114 "widely spaced, ",
115 TextRunProperties::new().with_character_spacing_points(3.0),
116 ))
117 .with_run(TextRun::text_with_properties(
118 "highlighted",
119 TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120 ))
121 .with_run(TextRun::text_with_properties(
122 "2",
123 TextRunProperties::new().with_baseline_percent(30.0),
124 )),
125 ),
126 );
127
128 let field_shape = AutoShape::new(2, "Field")
129 .with_properties(
130 ShapeProperties::new().with_transform(
131 Transform2D::new()
132 .with_offset(838_200, 838_200)
133 .with_extent(3_000_000, 500_000),
134 ),
135 )
136 .with_text_body(
137 TextBody::new().with_paragraph(
138 TextParagraph::new()
139 .with_run(TextRun::text("Slide "))
140 .with_run(TextRun::field(
141 "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142 Some("slidenum".to_string()),
143 "1",
144 )),
145 ),
146 );
147
148 let presentation = Presentation::new()
149 .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150 .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151 .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152 .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153 .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155 presentation.save_to_file(&path)?;
156 println!("Wrote {}", path.display());
157 Ok(())
158}pub fn with_default_run_properties( self, properties: TextRunProperties, ) -> TextParagraphProperties
Trait Implementations§
Source§impl Clone for TextParagraphProperties
impl Clone for TextParagraphProperties
Source§fn clone(&self) -> TextParagraphProperties
fn clone(&self) -> TextParagraphProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more