我有一个MVC3 C#.Net网络应用程序。我正在使用Aspose.Words来创建MS Word文档。我要求不在文档中包含表格。但是,在文档的几行中,文本的对齐方式根据文本的宽度而不对齐 例如:
看起来不错
Proposal Name: My Proposal Date:04/24/2012
这不是
Proposal Name: My Prop Date:04/24/2012
应该是
Proposal Name: My Prop Date:04/24/2012
根据文本第一位的宽度,我需要以像素为单位计算宽度(我认为)并在必要时插入TAB。
任何想法如何做到这一点?
答案 0 :(得分:1)
答案 1 :(得分:0)
以下代码示例返回当前实体相对于页面左上角的边界矩形。
Document doc = new Document(MyDir + "in.docx");
LayoutCollector layoutCollector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
var renderObject = layoutCollector.GetEntity(para);
layoutEnumerator.Current = renderObject;
RectangleF location = layoutEnumerator.Rectangle;
Console.WriteLine(location);
}