Wiki Markup |
---|
{description} {excerpt}The [ParagraphFormatting|ParagraphFormatting] class is used to specify formatting that should be applied to a paragraph. It also represents the paragraph formatting of named styles in the document.{excerpt} {signature:C#} public sealed class ParagraphFormatting {signature}{signature:vb.net} Public NotInheritable Class ParagraphFormatting {signature} {remarks}There are two ways to obtain an instance of this class: Create a new normal paragraph formatting object using the [Document.CreateParagraphFormatting|Document.CreateParagraphFormatting()] method or access an existing style's paragraph formatting information using the [NamedStyle.ParagraphFormatting|NamedStyle.ParagraphFormatting] property. The {{ParagraphFormatting}} object that is returned can then be used in conjunction with methods in the [Element|Element] class to create paragraphs with specific formatting. The following example demonstrates both ways of getting paragraph formatting, first by retrieving the BodyText style's paragraph formatting from the document, second by retrieving a copy of the BodyText2 style's paragraph formatting. Then, some properties are set and the formatting is applied to a new paragraph. {remarks} {example}{code:csharp|title=C#} //--- Get BodyText paragraph formatting from Document WordApplication app = new WordApplication(); Document doc = app.Create(); ParagraphFormatting bodyTextFormatting = doc.CreateParagraphFormatting(); //--- Set some properties bodyTextFormatting.PageBreakBefore = true; bodyTextFormatting.TextJustification = ParagraphFormatting.Justification.Right; //--- Apply it to a new paragraph doc.InsertParagraphAfter(null, bodyTextFormatting); //--- Get paragraph formatting from BodyText2 Style WordApplication app = new WordApplication(); Document doc = app.Create(); ParagraphFormatting bodyText2Formatting = doc.Styles[NamedStyle.BuiltIn.BodyText2].ParagaphFormatting; //--- Set some properties bodyText2Formatting.PageBreakBefore = true; bodyText2Formatting.TextJustification = ParagraphFormatting.Justification.Right; //--- Apply it to a new paragraph doc.InsertParagraphAfter(null, bodyText2Formatting); {code} {code:vb.net|title=vb.net} '--- Get BodyText paragraph formatting from Document Dim app As New WordApplication() Dim doc As Document = app.Create() Dim bodyTextFormatting As ParagraphFormatting = _ doc.CreateParagraphFormatting() '--- Set some properties bodyTextFormatting.PageBreakBefore = True bodyTextFormatting.TextJustification = _ ParagraphFormatting.Justification.Right '--- Apply it to a new paragraph doc.InsertParagraphAfter(Nothing, bodyTextFormatting) '--- Get paragraph formatting from BodyText2 Style Dim app As New WordApplication() Dim doc As Document = app.Create() Dim bodyText2Formatting As ParagraphFormatting = _ doc.Styles(NamedStyle.BuiltIn.BodyText2).ParagraphFormatting '--- Set some properties bodyText2Formatting.PageBreakBefore = True bodyText2Formatting.TextJustification = _ ParagraphFormatting.Justification.Right '--- Apply it to a new paragraph doc.InsertParagraphAfter(Nothing, bodyText2Formatting) {code} {example} {properties} ||Name||Description|| |[AbsolutePositioning|ParagraphFormatting.AbsolutePositioning]|{excerpt-include:ParagraphFormatting.AbsolutePositioning|nopanel=true}| |[AfterAutoSpacing|ParagraphFormatting.AfterAutoSpacing]|{excerpt-include:ParagraphFormatting.AfterAutoSpacing|nopanel=true}| |[AllowAutoHyphenation|ParagraphFormatting.AllowAutoHyphenation]|{excerpt-include:ParagraphFormatting.AllowAutoHyphenation|nopanel=true}| |[BeforeAutoSpacing|ParagraphFormatting.BeforeAutoSpacing]|{excerpt-include:ParagraphFormatting.BeforeAutoSpacing|nopanel=true}| |[KeepLinesTogether|ParagraphFormatting.KeepLinesTogether]|{excerpt-include:ParagraphFormatting.KeepLinesTogether|nopanel=true}| |[KeepWithNext|ParagraphFormatting.KeepWithNext]|{excerpt-include:ParagraphFormatting.KeepWithNext|nopanel=true}| |[LineNumberingAllowed|ParagraphFormatting.LineNumberingAllowed]|{excerpt-include:ParagraphFormatting.LineNumberingAllowed|nopanel=true}| |[LineSpacing|ParagraphFormatting.LineSpacing]|{excerpt-include:ParagraphFormatting.LineSpacing|nopanel=true}| |[LineSpacingRule|ParagraphFormatting.LineSpacingRule]|{excerpt-include:ParagraphFormatting.LineSpacingRule|nopanel=true}| |[PageBreakBefore|ParagraphFormatting.PageBreakBefore]|{excerpt-include:ParagraphFormatting.PageBreakBefore|nopanel=true}| |[Shading|ParagraphFormatting.Shading]|{excerpt-include:ParagraphFormatting.Shading|nopanel=true}| |[SpaceAfter|ParagraphFormatting.SpaceAfter]|{excerpt-include:ParagraphFormatting.SpaceAfter|nopanel=true}| |[SpaceBefore|ParagraphFormatting.SpaceBefore]|{excerpt-include:ParagraphFormatting.SpaceBefore|nopanel=true}| |[TextJustification|ParagraphFormatting.TextJustification]|{excerpt-include:ParagraphFormatting.TextJustification|nopanel=true}| |[WidowControl|ParagraphFormatting.WidowControl]|{excerpt-include:ParagraphFormatting.WidowControl|nopanel=true}| {methods} ||Name||Description|| |[GetBorder(Border.Location)|ParagraphFormatting.GetBorder(Border.Location)]|{excerpt-include:ParagraphFormatting.GetBorder(Border.Location)|nopanel=true}| |[GetIndent(ParagraphFormatting.IndentLocation)|ParagraphFormatting.GetIndent(ParagraphFormatting.IndentLocation)]|{excerpt-include:ParagraphFormatting.GetIndent(ParagraphFormatting.IndentLocation)|nopanel=true}| |[SetIndent(Int32, ParagraphFormatting.IndentLocation)|ParagraphFormatting.SetIndent(Int32, ParagraphFormatting.IndentLocation)]|{excerpt-include:ParagraphFormatting.SetIndent(Int32, ParagraphFormatting.IndentLocation)|nopanel=true}| |[SetLineSpacing(Int32, ParagraphFormatting.SpacingRule)|ParagraphFormatting.SetLineSpacing(Int32, ParagraphFormatting.SpacingRule)]|{excerpt-include:ParagraphFormatting.SetLineSpacing(Int32, ParagraphFormatting.SpacingRule)|nopanel=true}| {classes} ||Name||Description|| |[FontAlignment|ParagraphFormatting.FontAlignment]|{excerpt-include:ParagraphFormatting.FontAlignment|nopanel=true}| |[IndentLocation|ParagraphFormatting.IndentLocation]|{excerpt-include:ParagraphFormatting.IndentLocation|nopanel=true}| |[Justification|ParagraphFormatting.Justification]|{excerpt-include:ParagraphFormatting.Justification|nopanel=true}| |[SpacingRule|ParagraphFormatting.SpacingRule]|{excerpt-include:ParagraphFormatting.SpacingRule|nopanel=true}| |
Page History
Overview
Content Tools