本文整理汇总了C#中DocumentBuilder.MoveToParagraph方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.MoveToParagraph方法的具体用法?C# DocumentBuilder.MoveToParagraph怎么用?C# DocumentBuilder.MoveToParagraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.MoveToParagraph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveToParagraph
public static void MoveToParagraph(string dataDir)
{
// ExStart:DocumentBuilderMoveToParagraph
Document doc = new Document(dataDir + "DocumentBuilder.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Parameters are 0-index. Moves to third paragraph.
builder.MoveToParagraph(2, 0);
builder.Writeln("This is the 3rd paragraph.");
// ExEnd:DocumentBuilderMoveToParagraph
}
示例2: DocumentBuilderMoveToParagraph
public void DocumentBuilderMoveToParagraph()
{
//ExStart
//ExFor:DocumentBuilder.MoveToParagraph
//ExId:DocumentBuilderMoveToParagraph
//ExSummary:Shows how to move a cursor position to the specified paragraph.
Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Parameters are 0-index. Moves to third paragraph.
builder.MoveToParagraph(2, 0);
builder.Writeln("This is the 3rd paragraph.");
//ExEnd
}
示例3: EnsureQuoteField
/// <summary>
/// Ensure that the quote field is present at the start of the given document.
/// </summary>
public static void EnsureQuoteField(Document document)
{
var container = GetReferenceFieldContainer(document);
if (container == null)
throw new Exception("Unable to place quote reference field: no paragraph could be found.");
// If the first field in the document is "SET q", then exit early
var firstField = container.FirstChild as FieldStart;
if (firstField != null && IsQuoteField(firstField))
return;
// Otherwise, insert "SET q"
var builder = new DocumentBuilder(document);
if (container.FirstChild != null)
{
// Insert the new field at the beginning of the first paragraph
var field = builder.InsertField(" SET q \"\\\"\" ");
var insertBefore = container.FirstChild;
foreach (var node in field.Start.GetSelfAndFollowingSiblings().TakeUpToNode(field.End).Reverse().ToArray())
{
container.InsertBefore(node, insertBefore);
insertBefore = node;
}
}
else
{
// The paragraph is empty, so just insert the field
builder.MoveToParagraph(0, 0);
builder.InsertField(" SET q \"\\\"\" ");
}
}