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

Free Support Forum - aspose.com

Custom styles


I was reading the documentation http://www.aspose.com/docs/display/wordsjava/Font and specifically, the following example:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a paragraph style and specify some formatting for it.
Style style = doc.getStyles().add(StyleType.PARAGRAPH, “MyStyle1”);

// Create a list and make sure the paragraphs that use this style will use this list.

// Apply the paragraph style to the current paragraph in the document and add some text.
builder.writeln(“Hello World: MyStyle1, bulleted.”);

// Change to a paragraph style that has no list formatting.
builder.writeln(“Hello World: Normal.”);

builder.getDocument().save(getMyDir() + “Lists.ParagraphStyleBulleted Out.doc”);

Can you please tell me how do you define the MyStyle1 custom style. I can see how you use it by adding it in the Styles of the paragraph, but how you define what MyStyle1 is?

Ok, maybe I’m blind!! The answer is apparent on the example you provided, but I cannot delete the current post.

Hi Giorgos,

Thanks for your inquiry. The StyleCollection.add method creates a new user defined style and adds it the collection. You can create character, paragraph or a list style.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.