Hello,
I’m trying to add Chapter number in the beginning of my template. I created a mergefield for this so that the mergefield is replaced with the Chapter number, but it didn’t work (or is there a way to replace the mergefield with chapter information?) So, I wrote the following code (in Java):
Document ch1Doc = new Document(aBlobStream); //The document stored as a blob data in the database.
ch1Doc.getMailMerge().execute(
new String[] {"STPNumber", "STPDate"},
new Object[] {stp.getStpnumber(), pubDate}); //There are two mergefields, so I update these fields before inserting the chapter.
DocumentBuilder ch1Builder = new DocumentBuilder(ch1Doc);
Style style = ch1Doc.getStyles().add(StyleType.PARAGRAPH, "chapterStyle");
ch1Builder.getParagraphFormat().setStyle(ch1Doc.getStyles().get("Heading 1"));
style.getListFormat().setList(ch1Doc.getLists().add(ListTemplate.OUTLINE_HEADINGS_CHAPTER));
style.getListFormat().setListLevelNumber(0);
Instead of hard coding the chapter number (such as docbuilder.write (“Chapter 1”)), I 'm using Style so that my page number in the footer can be updated as “chapter number -1” format (like 1-1, 1-2, 1-3, etc). When I use the code above, the chapter number is printed out in the document correctely, but the message “Evauluation Only, Created with Aspose.Words…” follows after the chpater number.
Questions:
- Why the Evaluation message is appeared after the chapter number? Isn’t this message supposed to be printed out in the very beginning of the document?
- Is there a way to replace a mergefield with this style so that the chapter number appears at a designated location? I don’t want to, again, hard-code the chapter number. I need to use OUTLINE_HEADINGS_CHAPTER so that the page number is updated accordinlgy based on the chapter number.
Please help.
Thanks.
michelle