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

Free Support Forum - aspose.com

Issue with Bullets and numbering feature with Aspose Word for Java

Hi,
Recently I have upgraded to Aspose2.0.2 and noticed that it doesn’t merge document correctly, if in case document contains auto numbers.
All auto numbers are converted to 1. in merged document.
This functionality use to work with previous versions
Please look at attched document for example.
I am also attaching the code which I used to merge documents.

-Sunil


==========================================

static void testMergeDocuments() throws Exception
{
Document dstDoc = new Document(“C:/data/dst.doc”);
Document srcDoc = new Document(“C:/data/src.doc”);

DocumentBuilder builder = new DocumentBuilder(dstDoc);
srcDoc.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);




Bookmarks bk = dstDoc.getRange().getBookmarks();
FormField field = dstDoc.getRange().getFormFields().get(0);
Node endNode = getFormFieldEndNode(field,bk);
builder.moveTo(endNode);
dstDoc.getRange().getFormFields().remove(field);
BookmarkStart start = builder.startBookmark(“123”);
Paragraph pNode = (Paragraph)start.getParentNode();
Body bNode = (Body)pNode.getParentNode();

Sections sec = srcDoc.getSections();
Iterator secIt = sec.iterator();
Node insertAfterNode = pNode;
while(secIt.hasNext())
{
Section srcSection = (Section)secIt.next();
Body secBody = srcSection.getBody();

Iterator it = secBody.iterator();
while(it.hasNext())
{
Node n = (Node)it.next();
Node dstSection = dstDoc.importNode(n, true, ImportFormatMode.KEEP_SOURCE_FORMATTING);
bNode.insertAfter(dstSection,insertAfterNode);
insertAfterNode = dstSection;
}
}

builder.endBookmark(“123”);
dstDoc.save(“C:/data/out.doc”);
}

Hi,

Could you please attach the original documents as well to enable us reproduce the issue?

Please find the attached zip file.
src.doc and dst.doc are two file which are getting merged to generated out.doc

-Sunil

Unfortunately, we are still unable to run your code because the getFormFieldEndNode method is missed. Could you please post all your code necessary for replication?

We’ve commented it and are looking into the issue. However, if the missed code does make sense, please post it here nevertheless.

Hi, Sunil,

You should use NodeImporter to correctly import styles and list formatting as well. The thing is that word stores styles and list formatting centrally, separately from the text itself. And NodeImporter helps to import styles and formatting together with the text referencing its.

Document srcDoc = new Document("C:/data/src.doc");

Document dstDoc = new Document("C:/data/dst.doc");

//The NodeImporter imports (when needed) styles and list formatting that linked

//to a text of a source document but stored centrally, separately from the text itself.

NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);

srcDoc.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);

Section srcSection = srcDoc.getSections().get(0);

Section dstSection = (Section)importer.importNode(srcSection, true);

dstDoc.getSections().add(dstSection);

dstDoc.save("C:/data/out.doc");

Best Regards,

Thanks for the quick response.
With NodeImporter it works perfectly.

-Sunil