shape.Text.Story.Alignment
段落水平对齐(cdrAlignment 枚举)。
签名
shape.Text.Story.Alignment
说明
段落水平对齐(cdrAlignment 枚举)。
Python 示例(可直接运行)
Python
shape = app.ActiveSelectionRange(1)
# 段落对齐:以 cdrAlignment 为准(1左 2右 3中 4两端)
shape.Text.Story.Alignment = 3
print("已设为居中对齐")
关于本类:Text 文本对象
文字接口分两层:Shape.Text 是入口,真正读写字体字号要下到 Story.Characters.All。
- 本类共 13 条,这是其中之一。
- 完整分类见:Text 文本对象
同类其他接口
- shape.Text文字对象入口。只有 shape.Type == 6 时才存在。
- shape.Text.Contents纯文本内容,可读可写。读之前先 strip(),CDR 常在末尾带空格,导致判断错。
- shape.Text.IsArtisticText是否美术字(单行标题)。True/False。
- shape.Text.IsParagraphText是否段落文本(区域内换行)。
- shape.Text.Story文本故事对象,所有排版属性的真正载体。
- shape.Text.Story.Characters字符集合。.Count 拿字数,.Item(i) 拿单个字符。
- shape.Text.Story.Characters.All整段字符范围,这是唯一可靠的批量字体/字号入口。Text.FontProperties 会静默吞掉字号设置,别用它。
- shape.Text.Story.CharSpacing字距,单位是百分比。代码里 180 = 180% 的疏排,50 = 收紧。中文标题加宽靠它。