We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Center Aligining a Text

Hi,

Could you please provide me a sample code, which demonstrate Center-Alignment in Aspose.Word.

I have a requirement, where i have to set my page heading to center.

Thanks,

Siraj

Hi

Thanks for your inquiry. Please see the following example.

//Create new document and DocumentBuilder

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Set alignment of text and other formating

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.Font.Size = 16;

builder.Font.Bold = true;

//Insert text

builder.Write("This is centered text");

//Save document

doc.Save(@"Test095\out.doc");

Also see documentation for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/paragraph-formatting.html

Best regards.