ParagraphFormat

ParagraphFormat class

Represents all the formatting for a paragraph.

To learn more, visit the Working with Paragraphs documentation article.

public class ParagraphFormat

Properties

NameDescription
AddSpaceBetweenFarEastAndAlpha { get; set; }Gets or sets a flag indicating whether inter-character spacing is automatically adjusted between regions of Latin text and regions of East Asian text in the current paragraph.
AddSpaceBetweenFarEastAndDigit { get; set; }Gets or sets a flag indicating whether inter-character spacing is automatically adjusted between regions of numbers and regions of East Asian text in the current paragraph.
Alignment { get; set; }Gets or sets text alignment for the paragraph.
BaselineAlignment { get; set; }Gets or sets fonts vertical position on a line.
Bidi { get; set; }Gets or sets whether this is a right-to-left paragraph.
Borders { get; }Gets collection of borders of the paragraph.
CharacterUnitFirstLineIndent { get; set; }Gets or sets the value (in characters) for the first-line or hanging indent.
CharacterUnitLeftIndent { get; set; }Gets or sets the left indent value (in characters) for the specified paragraphs.
CharacterUnitRightIndent { get; set; }Gets or sets the right indent value (in characters) for the specified paragraphs.
DropCapPosition { get; set; }Gets or sets the position for a drop cap text.
FarEastLineBreakControl { get; set; }Gets or sets a flag indicating whether East Asian line-breaking rules are applied to the current paragraph.
FirstLineIndent { get; set; }Gets or sets the value (in points) for a first line or hanging indent.
HangingPunctuation { get; set; }Gets or sets a flag indicating whether hanging punctuation is enabled for the current paragraph.
IsHeading { get; }True when the paragraph style is one of the built-in Heading styles.
IsListItem { get; }True when the paragraph is an item in a bulleted or numbered list.
KeepTogether { get; set; }True if all lines in the paragraph are to remain on the same page.
KeepWithNext { get; set; }True if the paragraph is to remains on the same page as the paragraph that follows it.
LeftIndent { get; set; }Gets or sets the value (in points) that represents the left indent for paragraph.
LineSpacing { get; set; }Gets or sets the line spacing (in points) for the paragraph.
LineSpacingRule { get; set; }Gets or sets the line spacing for the paragraph.
LinesToDrop { get; set; }Gets or sets the number of lines of the paragraph text used to calculate the drop cap height.
LineUnitAfter { get; set; }Gets or sets the amount of spacing (in gridlines) after the paragraphs.
LineUnitBefore { get; set; }Gets or sets the amount of spacing (in gridlines) before the paragraphs.
MirrorIndents { get; set; }Gets or sets a flag indicating whether the left and right indents are of the same width.
NoSpaceBetweenParagraphsOfSameStyle { get; set; }When true, SpaceBefore and SpaceAfter will be ignored between the paragraphs of the same style.
OutlineLevel { get; set; }Specifies the outline level of the paragraph in the document.
PageBreakBefore { get; set; }True if a page break is forced before the paragraph.
RightIndent { get; set; }Gets or sets the value (in points) that represents the right indent for paragraph.
Shading { get; }Returns a Shading object that refers to the shading formatting for the paragraph.
SnapToGrid { get; set; }Specifies whether the current paragraph should use the document grid lines per page settings when laying out the contents in the paragraph.
SpaceAfter { get; set; }Gets or sets the amount of spacing (in points) after the paragraph.
SpaceAfterAuto { get; set; }True if the amount of spacing after the paragraph is set automatically.
SpaceBefore { get; set; }Gets or sets the amount of spacing (in points) before the paragraph.
SpaceBeforeAuto { get; set; }True if the amount of spacing before the paragraph is set automatically.
Style { get; set; }Gets or sets the paragraph style applied to this formatting.
StyleIdentifier { get; set; }Gets or sets the locale independent style identifier of the paragraph style applied to this formatting.
StyleName { get; set; }Gets or sets the name of the paragraph style applied to this formatting.
SuppressAutoHyphens { get; set; }Specifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings.
SuppressLineNumbers { get; set; }Specifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section.
TabStops { get; }Gets the collection of custom tab stops defined for this object.
WidowControl { get; set; }True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph.
WordWrap { get; set; }If this property is false, Latin text in the middle of a word can be wrapped for the current paragraph. Otherwise Latin text is wrapped by whole words.

Methods

NameDescription
ClearFormatting()Resets to default paragraph formatting.

Examples

Shows how to construct an Aspose.Words document by hand.

Document doc = new Document();

// A blank document contains one section, one body and one paragraph.
// Call the "RemoveAllChildren" method to remove all those nodes,
// and end up with a document node with no children.
doc.RemoveAllChildren();

// This document now has no composite child nodes that we can add content to.
// If we wish to edit it, we will need to repopulate its node collection.
// First, create a new section, and then append it as a child to the root document node.
Section section = new Section(doc);
doc.AppendChild(section);

// Set some page setup properties for the section.
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = PaperSize.Letter;

// A section needs a body, which will contain and display all its contents
// on the page between the section's header and footer.
Body body = new Body(doc);
section.AppendChild(body);

// Create a paragraph, set some formatting properties, and then append it as a child to the body.
Paragraph para = new Paragraph(doc);

para.ParagraphFormat.StyleName = "Heading 1";
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

body.AppendChild(para);

// Finally, add some content to do the document. Create a run,
// set its appearance and contents, and then append it as a child to the paragraph.
Run run = new Run(doc);
run.Text = "Hello World!";
run.Font.Color = Color.Red;
para.AppendChild(run);

Assert.AreEqual("Hello World!", doc.GetText().Trim());

doc.Save(ArtifactsDir + "Section.CreateManually.docx");

See Also