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

Free Support Forum - aspose.com

Prefixed numbered paragraphs

Hello


I need to generate numbered paragraphs with several Heading styles with normal and custom prefixes and cross references, like:
2. Flow of events
2.1. Basic flow
2.2.1 Step 1
2.2.1 Step 2 [FA1]
2.2 Alternative flows
FA1. Include entity
This flows starts when…
1. The system shows…
2. The actor…
FA2. Change entity
This flows starts when…
1. The system shows…
2. The actor…[FE1]
2.2 Exception flows
FE1. File not found
At the step 2 of FA2, …
1. The system
2. …
I couldn’t find a way to generate headings like FA1, FA2 that can be updated by Word. I’m depending just on this to buy a license.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can use ListLevel.NumberFormat to specify custom number’s format:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/listlevel.html#NumberFormat

For example, see the following code:

Document doc = new Document();

// Create a list based on one of the Microsoft Word list templates.

List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

// Completely customize one list level.

ListLevel level1 = list.getListLevels().get(0);

level1.setNumberStyle(NumberStyle.ARABIC);

level1.setNumberFormat("\u0000.");

// Completely customize yet another list level.

ListLevel level2 = list.getListLevels().get(1);

level2.setNumberStyle(NumberStyle.ARABIC);

level2.setNumberFormat("FA\u0001.");

// Now add some text that uses the list that we created.

// It does not matter when to customize the list - before or after adding the paragraphs.

DocumentBuilder builder = new DocumentBuilder(doc);

builder.getListFormat().setList(list);

builder.writeln("The quick brown fox...");

builder.writeln("The quick brown fox...");

builder.getListFormat().listIndent();

builder.writeln("jumped over the lazy dog.");

builder.writeln("jumped over the lazy dog.");

builder.getListFormat().listOutdent();

builder.writeln("The quick brown fox...");

builder.getListFormat().removeNumbers();

doc.save("C:\\Temp\\out.doc");

Hope this helps. Please let me know if you need more information, I will be glad to help you.

Best regards,

Thank you for the quick response, and sorry for asking something that is documented.