Free Support Forum - aspose.com

How can I get Font Style and Indentation Level of a Paragraph?

Hello,

I am using Aspose.Word’s DocumentVisitor class to read a word document. I am using VisitParagraphStart function to go through each paragraph one by one. Now, my problem is that I need to get the Format and indentation level of the current paragraph I am in. Can you please show me or point me to an article that can shows how can I do this?


Here is the example of what I want to do:


Public Overrides Function VisitParagraphStart(ByVal paragraph As Aspose.Words.Paragraph) As Aspose.Words.VisitorAction

'Get the Font Name of current Paragraph.

'Get the Font Size of current paragraph.

'Get the Font Style (B/I/U) of current Paragraph

'Get the Indentation Level of current Paragraph

End Function

Thanks very much in advance.

Jerry.

Hi

Thanks for your request. You can try to use ParagraphFormat class to get these values. See the following link for more information.

http://www.aspose.com/Products/Aspose.Words/Api/Aspose.Words.ParagraphFormat.html

//Get the Font Name of current Paragraph.

paragraph.ParagraphFormat.Style.Font.Name;

//Get the Font Size of current paragraph.

paragraph.ParagraphFormat.Style.Font.Size;

//Get the Font Style (B/I/U) of current Paragraph

paragraph.ParagraphFormat.Style.Font.Bold;

paragraph.ParagraphFormat.Style.Font.Italic;

if (paragraph.ParagraphFormat.Style.Font.Underline != Underline.None)

{

//is Underlined

}

//Get the Indentation Level of current Paragraph

paragraph.ParagraphFormat.LeftIndent;

paragraph.ParagraphFormat.RightIndent;

paragraph.ParagraphFormat.FirstLineIndent;

I hope that it will help you.

Best regards.