Aspose::Words::ParagraphFormat class

ParagraphFormat class

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

class ParagraphFormat : public IBorderAttrSource,
                        public IShadingAttrSource

Methods

MethodDescription
ClearFormatting()Resets to default paragraph formatting.
get_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.
get_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.
get_Alignment()Gets or sets text alignment for the paragraph.
get_BaselineAlignment()Gets or sets fonts vertical position on a line.
get_Bidi()Gets or sets whether this is a right-to-left paragraph.
get_Borders()Gets collection of borders of the paragraph.
get_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.
get_CharacterUnitLeftIndent()Gets or sets the left indent value (in characters) for the specified paragraphs.
get_CharacterUnitRightIndent()Gets or sets the right indent value (in characters) for the specified paragraphs.
get_DropCapPosition()Gets or sets the position for a drop cap text.
get_FarEastLineBreakControl()Gets or sets a flag indicating whether East Asian line-breaking rules are applied to the current paragraph.
get_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.
get_HangingPunctuation()Gets or sets a flag indicating whether hanging punctuation is enabled for the current paragraph.
get_IsHeading()True when the paragraph style is one of the built-in Heading styles.
get_IsListItem()True when the paragraph is an item in a bulleted or numbered list.
get_KeepTogether()True if all lines in the paragraph are to remain on the same page.
get_KeepWithNext()True if the paragraph is to remains on the same page as the paragraph that follows it.
get_LeftIndent()Gets or sets the value (in points) that represents the left indent for paragraph.
get_LineSpacing()Gets or sets the line spacing (in points) for the paragraph.
get_LineSpacingRule()Gets or sets the line spacing for the paragraph.
get_LineUnitAfter()Gets or sets the amount of spacing (in gridlines) after the paragraphs.
get_LineUnitBefore()Gets or sets the amount of spacing (in gridlines) before the paragraphs.
get_LinesToDrop()Gets or sets the number of lines of the paragraph text used to calculate the drop cap height.
get_MirrorIndents()Gets or sets a flag indicating whether the left and right indents are of the same width.
get_NoSpaceBetweenParagraphsOfSameStyle()When true, SpaceBefore and SpaceAfter will be ignored between the paragraphs of the same style.
get_OutlineLevel()Specifies the outline level of the paragraph in the document.
get_PageBreakBefore()True if a page break is forced before the paragraph.
get_RightIndent()Gets or sets the value (in points) that represents the right indent for paragraph.
get_Shading()Returns a Shading object that refers to the shading formatting for the paragraph.
get_SnapToGrid()Specifies whether the current paragraph should use the document grid lines per page settings when laying out the contents in the paragraph.
get_SpaceAfter()Gets or sets the amount of spacing (in points) after the paragraph.
get_SpaceAfterAuto()True if the amount of spacing after the paragraph is set automatically.
get_SpaceBefore()Gets or sets the amount of spacing (in points) before the paragraph.
get_SpaceBeforeAuto()True if the amount of spacing before the paragraph is set automatically.
get_Style()Gets or sets the paragraph style applied to this formatting.
get_StyleIdentifier()Gets or sets the locale independent style identifier of the paragraph style applied to this formatting.
get_StyleName()Gets or sets the name of the paragraph style applied to this formatting.
get_SuppressAutoHyphens()Specifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings.
get_SuppressLineNumbers()Specifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section.
get_TabStops()Gets the collection of custom tab stops defined for this object.
get_WidowControl()True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph.
get_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.
set_AddSpaceBetweenFarEastAndAlpha(bool)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.
set_AddSpaceBetweenFarEastAndDigit(bool)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.
set_Alignment(Aspose::Words::ParagraphAlignment)Sets text alignment for the paragraph.
set_BaselineAlignment(Aspose::Words::BaselineAlignment)Sets fonts vertical position on a line.
set_Bidi(bool)Sets whether this is a right-to-left paragraph.
set_CharacterUnitFirstLineIndent(double)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.
set_CharacterUnitLeftIndent(double)Sets the left indent value (in characters) for the specified paragraphs.
set_CharacterUnitRightIndent(double)Sets the right indent value (in characters) for the specified paragraphs.
set_DropCapPosition(Aspose::Words::DropCapPosition)Sets the position for a drop cap text.
set_FarEastLineBreakControl(bool)Sets a flag indicating whether East Asian line-breaking rules are applied to the current paragraph.
set_FirstLineIndent(double)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.
set_HangingPunctuation(bool)Sets a flag indicating whether hanging punctuation is enabled for the current paragraph.
set_KeepTogether(bool)True if all lines in the paragraph are to remain on the same page.
set_KeepWithNext(bool)True if the paragraph is to remains on the same page as the paragraph that follows it.
set_LeftIndent(double)Sets the value (in points) that represents the left indent for paragraph.
set_LineSpacing(double)Sets the line spacing (in points) for the paragraph.
set_LineSpacingRule(Aspose::Words::LineSpacingRule)Sets the line spacing for the paragraph.
set_LineUnitAfter(double)Sets the amount of spacing (in gridlines) after the paragraphs.
set_LineUnitBefore(double)Sets the amount of spacing (in gridlines) before the paragraphs.
set_LinesToDrop(int32_t)Sets the number of lines of the paragraph text used to calculate the drop cap height.
set_MirrorIndents(bool)Sets a flag indicating whether the left and right indents are of the same width.
set_NoSpaceBetweenParagraphsOfSameStyle(bool)When true, SpaceBefore and SpaceAfter will be ignored between the paragraphs of the same style.
set_OutlineLevel(Aspose::Words::OutlineLevel)Specifies the outline level of the paragraph in the document.
set_PageBreakBefore(bool)True if a page break is forced before the paragraph.
set_RightIndent(double)Sets the value (in points) that represents the right indent for paragraph.
set_SnapToGrid(bool)Specifies whether the current paragraph should use the document grid lines per page settings when laying out the contents in the paragraph.
set_SpaceAfter(double)Sets the amount of spacing (in points) after the paragraph.
set_SpaceAfterAuto(bool)True if the amount of spacing after the paragraph is set automatically.
set_SpaceBefore(double)Sets the amount of spacing (in points) before the paragraph.
set_SpaceBeforeAuto(bool)True if the amount of spacing before the paragraph is set automatically.
set_Style(const System::SharedPtr<Aspose::Words::Style> &)Sets the paragraph style applied to this formatting.
set_StyleIdentifier(Aspose::Words::StyleIdentifier)Sets the locale independent style identifier of the paragraph style applied to this formatting.
set_StyleName(const System::String &)Sets the name of the paragraph style applied to this formatting.
set_SuppressAutoHyphens(bool)Specifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings.
set_SuppressLineNumbers(bool)Specifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section.
set_WidowControl(bool)True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph.
set_WordWrap(bool)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.

Examples

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

auto doc = System::MakeObject<Aspose::Words::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.
auto section = System::MakeObject<Aspose::Words::Section>(doc);
doc->AppendChild<System::SharedPtr<Aspose::Words::Section>>(section);

// Set some page setup properties for the section.
section->get_PageSetup()->set_SectionStart(SectionStart::NewPage);
section->get_PageSetup()->set_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.
auto body = System::MakeObject<Aspose::Words::Body>(doc);
section->AppendChild<System::SharedPtr<Aspose::Words::Body>>(body);

// Create a paragraph, set some formatting properties, and then append it as a child to the body.
auto para = System::MakeObject<Aspose::Words::Paragraph>(doc);

para->get_ParagraphFormat()->set_StyleName(u"Heading 1");
para->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);

body->AppendChild<System::SharedPtr<Aspose::Words::Paragraph>>(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.
auto run = System::MakeObject<Aspose::Words::Run>(doc);
run->set_Text(u"Hello World!");
run->get_Font()->set_Color(System::Drawing::Color::get_Red());
para->AppendChild<System::SharedPtr<Aspose::Words::Run>>(run);

ASSERT_EQ(doc->GetText().Trim(), u"Hello World!");

doc->Save(get_ArtifactsDir() + u"Section.CreateManually.docx");

See Also