Skip to main content

Module textbox

Module textbox 

Source
Expand description

TextBox:纯文本框(<p:sp> + prstGeom="rect" + txBody)。

AutoShape 区别在于:TextBox 强制 prstGeom=rect、bodyPr 默认无填充无外框,更接近“传统文本框“语义。

§与 python-pptx 的对应

  • pptx.shapes.textbox.TextBox ←→ TextBox
  • Slide.shapes.add_textbox(left, top, width, height) 返回 TextBox

§文本替换语义

TextBox::set_text 的语义是“替换全部段落“——每行(\n 分隔)变成一段; 旧的字体/颜色属性会被丢弃。如需保留属性,请直接 mutate TextBox::text_frame_mut

§示例

use pptx_rs::shape::TextBox;

let mut tb = TextBox::new("MyTextBox");
tb.set_text("Hello\nWorld");
assert_eq!(tb.text(), "Hello\nWorld");

Structs§

TextBox
文本框(python-pptx 的 shapes.add_textbox 对应)。