C# 使用Aspose.Words v13.1.0读取第一列的最后一行
我有一个word文档,有两列布局。 如何读取word文档中第一列的最后一行和第二列的第一行。如果第一列的最后一行文本为特定格式,则向下移动一行,这将自动将文本移动到下一列(第二列)C# 使用Aspose.Words v13.1.0读取第一列的最后一行,c#,aspose,C#,Aspose,我有一个word文档,有两列布局。 如何读取word文档中第一列的最后一行和第二列的第一行。如果第一列的最后一行文本为特定格式,则向下移动一行,这将自动将文本移动到下一列(第二列) 请让我知道如何在.net中使用Aspose.Words V13.1.0实现这一点。首先,您需要从下载脱机示例包以使用以下代码示例。然后提取归档文件,并从DocumentLayoutHelper示例中,将RenderedDocument和LayoutTities源文件包含到其应用程序中 以下是示例代码: Documen
请让我知道如何在.net中使用Aspose.Words V13.1.0实现这一点。首先,您需要从下载脱机示例包以使用以下代码示例。然后提取归档文件,并从DocumentLayoutHelper示例中,将RenderedDocument和LayoutTities源文件包含到其应用程序中 以下是示例代码:
Document doc = new Document(dataDir + "Test.docx");
// This sample introduces the RenderedDocument class and other related classes which provide an API wrapper for
// the LayoutEnumerator. This allows you to access the layout entities of a document using a DOM style API.
// Create a new RenderedDocument class from a Document object.
RenderedDocument layoutDoc = new RenderedDocument(doc);
// Loop through the layout info of each page
foreach (RenderedPage page in layoutDoc.Pages)
{
if (page.Columns.Count > 1)
{
// Find the last line in the first column on the page.
RenderedLine lastLine = page.Columns.First.Lines.Last;
// This is the pargraph which belongs to the last line on the page, implement required logic and checks here.
Paragraph para = lastLine.Paragraph;
if (para.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1)
{
// Insert a blank paragraph before the last paragraph in the column.
para.ParentNode.InsertBefore(new Paragraph(doc), para);
}
// This is how to get the first line in the second column and the related paragraph.
// Use this if it is required.
RenderedLine secondColumnLine = page.Columns[1].Lines.First;
Paragraph secondColumnPara = lastLine.Paragraph;
}
}
PS,希望以上示例能够满足您的要求。我的名字是Nayyer,我是Aspose的支持/工程师开发人员。请展示一些源代码。。。你试过什么?到底是什么不起作用(异常/错误消息)?请告诉我Stackoverflow上不欢迎使用codez类型的问题。在提出更多问题之前,请阅读本手册。