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

Free Support Forum - aspose.com

Appending documents an update Lists messes up the indent's

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545; min-height: 14.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #e4af09} span.s1 {color: #454545} span.s2 {color: #e4af09}

Hello,


Pleas find enclosed 4 files : 1 java class with main method and 3 word docx.

I want to append one document to another, but to prevent the numbering to continue,

I used the code I found in the Aspose doc : https://docs.aspose.com//display/wordsandroid/Controlling+How+Lists+are+Handled


In the result (after running the code you’ll find it in file TestFile.ListUseDestinationStyles_Out.docx) you’ll see that the

second list has a left indent of 0,63cm. Any ideas where this indent is coming from ? It messes up my layout…


I uploaded my final result in TestFile.ListUseDestinationStyles_Out.docx file.


My Java code sits in the TestCopyList.txt file


thanks,

Chris

Hi Chris,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15022. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Could you please share which of the following product you are using?

Aspose.Words for Java
Aspose.Words for Android

Hello,


We are using Aspose.Words for Java version 16.4.0


Grtz,

Chris.


p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
span.Apple-tab-span {white-space:pre}
Hi Chris,

Thanks for sharing the detail.

We will inform you via this forum thread once this issue is resolved. Please let us know if you have any more queries.

Hi Chris,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-15022) as 'Not a Bug'.

Please use the following highlighted code snippet to get the desired output.

Document dstDoc = new Document(MyDir + "TestFile.DestinationList.docx");
Document srcDoc = new Document(MyDir + "TestFile.SourceList.docx");

// Set the source document to continue straight after the end of the destination document.
srcDoc.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);

// Keep track of the lists that are created.
HashMap newLists = new HashMap();

// Iterate through all paragraphs in the document.
for (Paragraph para : (Iterable) srcDoc.getChildNodes(NodeType.PARAGRAPH, true))
{
if (para.isListItem())
{
int listId = para.getListFormat().getList().getListId();

// Check if the destination document contains a list with this ID already. If it does then this may
// cause the two lists to run together. Create a copy of the list in the source document instead.
if (dstDoc.getLists().getListByListId(listId) != null)
{
List currentList;
// A newly copied list already exists for this ID, retrieve the stored list and use it on
// the current paragraph.
if (newLists.containsKey(listId))
{
currentList = (List)newLists.get(listId);
}
else
{
// Add a copy of this list to the document and store it for later reference.
currentList = srcDoc.getLists().addCopy(para.getListFormat().getList());
newLists.put(listId, currentList);
}

double leftIndent = para.getParagraphFormat().getLeftIndent();
// Set the list of this paragraph to the copied list.
para.getListFormat().setList(currentList);

para.getParagraphFormat().setLeftIndent(leftIndent);

}
}
}

// Append the source document to end of the destination document.
dstDoc.appendDocument(srcDoc, ImportFormatMode.USE_DESTINATION_STYLES);

// Save the combined document to disk.
dstDoc.save(MyDir + "output.docx");