ParagraphFormat class
ParagraphFormat class
Represents all the formatting for a paragraph. To learn more, visit the Working with Paragraphs documentation article.
Properties
Name | Description |
---|---|
addSpaceBetweenFarEastAndAlpha | 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 | 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 | Gets or sets text alignment for the paragraph. |
baselineAlignment | Gets or sets fonts vertical position on a line. |
bidi | Gets or sets whether this is a right-to-left paragraph. |
borders | Gets collection of borders of the paragraph. |
characterUnitFirstLineIndent | Gets 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. |
characterUnitLeftIndent | Gets or sets the left indent value (in characters) for the specified paragraphs. |
characterUnitRightIndent | Gets or sets the right indent value (in characters) for the specified paragraphs. |
dropCapPosition | Gets or sets the position for a drop cap text. |
farEastLineBreakControl | Gets or sets a flag indicating whether East Asian line-breaking rules are applied to the current paragraph. |
firstLineIndent | Gets 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. |
hangingPunctuation | Gets or sets a flag indicating whether hanging punctuation is enabled for the current paragraph. |
isHeading | True when the paragraph style is one of the built-in Heading styles. |
isListItem | True when the paragraph is an item in a bulleted or numbered list. |
keepTogether | True if all lines in the paragraph are to remain on the same page. |
keepWithNext | True if the paragraph is to remains on the same page as the paragraph that follows it. |
leftIndent | Gets or sets the value (in points) that represents the left indent for paragraph. |
lineSpacing | Gets or sets the line spacing (in points) for the paragraph. |
lineSpacingRule | Gets or sets the line spacing for the paragraph. |
lineUnitAfter | Gets or sets the amount of spacing (in gridlines) after the paragraphs. |
lineUnitBefore | Gets or sets the amount of spacing (in gridlines) before the paragraphs. |
linesToDrop | Gets or sets the number of lines of the paragraph text used to calculate the drop cap height. |
mirrorIndents | Gets or sets a flag indicating whether the left and right indents are of the same width. |
noSpaceBetweenParagraphsOfSameStyle | When true , ParagraphFormat.spaceBefore and ParagraphFormat.spaceAfter will be ignored between the paragraphs of the same style. |
outlineLevel | Specifies the outline level of the paragraph in the document. |
pageBreakBefore | True if a page break is forced before the paragraph. |
rightIndent | Gets or sets the value (in points) that represents the right indent for paragraph. |
shading | Returns a Shading object that refers to the shading formatting for the paragraph. |
snapToGrid | Specifies whether the current paragraph should use the document grid lines per page settings when laying out the contents in the paragraph. |
spaceAfter | Gets or sets the amount of spacing (in points) after the paragraph. |
spaceAfterAuto | True if the amount of spacing after the paragraph is set automatically. |
spaceBefore | Gets or sets the amount of spacing (in points) before the paragraph. |
spaceBeforeAuto | True if the amount of spacing before the paragraph is set automatically. |
style | Gets or sets the paragraph style applied to this formatting. |
styleIdentifier | Gets or sets the locale independent style identifier of the paragraph style applied to this formatting. |
styleName | Gets or sets the name of the paragraph style applied to this formatting. |
suppressAutoHyphens | Specifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings. |
suppressLineNumbers | Specifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section. |
tabStops | Gets the collection of custom tab stops defined for this object. |
widowControl | True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph. |
wordWrap | 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
Name | Description |
---|---|
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
- module Aspose.Words