要获取段落的宽度,可以使用 Aspose.Words API 中的 ParagraphFormat 属性。以下是示例代码:

Document doc = new Document('input.docx');
Paragraph para = doc.FirstSection.Body.FirstParagraph;

double width = para.ParagraphFormat.RightIndent - para.ParagraphFormat.LeftIndent;
Console.WriteLine('Width in points: ' + width);
Console.WriteLine('Width in inches: ' + (width / 72.0));

上述代码中,我们首先获取文档中第一个段落对象。然后,我们使用段落的 ParagraphFormat 属性获取其左右缩进的值。通过减去左缩进值,我们可以得到段落的宽度。最后,我们将宽度转换为磅或英寸单位进行输出。

C# Aspose.Words 获取段落宽度 (磅为单位)

原文地址: https://www.cveoy.top/t/topic/nKaw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录