ParagraphFormat class

ParagraphFormat class

Represents all the formatting for a paragraph. To learn more, visit the Working with Paragraphs documentation article.

Properties

NameDescription
addSpaceBetweenFarEastAndAlphaGets 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.
addSpaceBetweenFarEastAndDigitGets 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.
alignmentGets or sets text alignment for the paragraph.
baselineAlignmentGets or sets fonts vertical position on a line.
bidiGets or sets whether this is a right-to-left paragraph.
bordersGets collection of borders of the paragraph.
characterUnitFirstLineIndentGets or sets the value (in characters) for the first-line or hanging indent. Use positive values to set the first-line indent, and negative values to set the hanging indent.
characterUnitLeftIndentGets or sets the left indent value (in characters) for the specified paragraphs.
characterUnitRightIndentGets or sets the right indent value (in characters) for the specified paragraphs.
dropCapPositionGets or sets the position for a drop cap text.
farEastLineBreakControlGets or sets a flag indicating whether East Asian line-breaking rules are applied to the current paragraph.
firstLineIndentGets or sets the value (in points) for a first line or hanging indent. Use positive values to set the first-line indent, and negative values to set the hanging indent.
hangingPunctuationGets or sets a flag indicating whether hanging punctuation is enabled for the current paragraph.
isHeadingTrue when the paragraph style is one of the built-in Heading styles.
isListItemTrue when the paragraph is an item in a bulleted or numbered list.
keepTogetherTrue if all lines in the paragraph are to remain on the same page.
keepWithNextTrue if the paragraph is to remains on the same page as the paragraph that follows it.
leftIndentGets or sets the value (in points) that represents the left indent for paragraph.
lineSpacingGets or sets the line spacing (in points) for the paragraph.
lineSpacingRuleGets or sets the line spacing for the paragraph.
lineUnitAfterGets or sets the amount of spacing (in gridlines) after the paragraphs.
lineUnitBeforeGets or sets the amount of spacing (in gridlines) before the paragraphs.
linesToDropGets or sets the number of lines of the paragraph text used to calculate the drop cap height.
mirrorIndentsGets or sets a flag indicating whether the left and right indents are of the same width.
noSpaceBetweenParagraphsOfSameStyleWhen true, ParagraphFormat.spaceBefore and ParagraphFormat.spaceAfter will be ignored between the paragraphs of the same style.
outlineLevelSpecifies the outline level of the paragraph in the document.
pageBreakBeforeTrue if a page break is forced before the paragraph.
rightIndentGets or sets the value (in points) that represents the right indent for paragraph.
shadingReturns a Shading object that refers to the shading formatting for the paragraph.
snapToGridSpecifies whether the current paragraph should use the document grid lines per page settings when laying out the contents in the paragraph.
spaceAfterGets or sets the amount of spacing (in points) after the paragraph.
spaceAfterAutoTrue if the amount of spacing after the paragraph is set automatically.
spaceBeforeGets or sets the amount of spacing (in points) before the paragraph.
spaceBeforeAutoTrue if the amount of spacing before the paragraph is set automatically.
styleGets or sets the paragraph style applied to this formatting.
styleIdentifierGets or sets the locale independent style identifier of the paragraph style applied to this formatting.
styleNameGets or sets the name of the paragraph style applied to this formatting.
suppressAutoHyphensSpecifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings.
suppressLineNumbersSpecifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section.
tabStopsGets the collection of custom tab stops defined for this object.
widowControlTrue if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph.
wordWrapIf 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.

let doc = new aw.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.
let section = new aw.Section(doc);
doc.appendChild(section);

// Set some page setup properties for the section.
section.pageSetup.sectionStart = aw.SectionStart.NewPage;
section.pageSetup.paperSize = aw.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.
let body = new aw.Body(doc);
section.appendChild(body);

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

para.paragraphFormat.styleName = "Heading 1";
para.paragraphFormat.alignment = aw.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.
let run = new aw.Run(doc);
run.text = "Hello World!";
run.font.color = "#FF0000";
para.appendChild(run);

expect(doc.getText().trim()).toEqual("Hello World!");

doc.save(base.artifactsDir + "Section.CreateManually.docx");

See Also