Hi,
I have to insert two files in a .dot file.
The two files has Heading Style:
First file has :
- Heading 1
- Heading 1
2.1 Heading 2
2.1.1 Heading 3
The second file has :
1.1.1 Heading 3
1.1.1.1 Heading 4.
When I insert the first and the second, the result is:
- Heading 1
- Heading 1
2.1. Heading 2
2.1.1 Heading 3
1.1.1 Heading 3
1.1.1.1 Heading 4.
Even if I put the option USE_DESTINATION_STYLES in the NodeImporter…
The particular thing is that I have to insert files through bookmarks.
Please find in attachment the File3.doc and File4.doc to insert, the .dot file and the output2.docx result.
And also my code (File TestInserV2.txt to rename into .java)
What am i doing wrong ?
Regards.
Hi Roseline,
Thanks for your query. I have tried to understand your query but unfortunately I have not completely understood your query. It would be great if you please share some more detail about your query.
I have merge your documents by using following code snippet. Please find the output document in attachment and let us know if there is any issue with output document.
Document doc1 = new Document(new File("D:\\File3.doc").getAbsolutePath());
Document doc1Clone = doc1.deepClone();
DocumentBuilder builder = new DocumentBuilder(doc1Clone);
Document wordDoc = new Document(new File("D:\\File4.doc").getAbsolutePath());
builder.moveToDocumentEnd();
insertDocument(builder.getCurrentParagraph(), wordDoc);
doc1Clone.save("D:\\output.docx");
Hi Tahir,
First of all, sorry for my bad english…
In my first post, I have attached a .dot file which contains two bookmarks.
The content of each bookmark is an url (url=“D:\File3.doc”).
I have to replace each bookmark by the content of the url’s file.
So the algorithm is :
- Get all bookmarks of the document (.dot template)
- For each
- Get the url
- Get the file
- Insert the file in the bookmark location
Here an extract of the code:
protected static void replaceBookmark(Document docTemplateClone, DocumentBuilder builder) throws Exception {
BookmarkCollection bookmarks = docTemplateClone.getRange().getBookmarks();
for (Bookmark bookmark : bookmarks) {
if (bookmark != null) {
String bookmarkName = bookmark.getName();
if (bookmarkName.startsWith("FileInsertion")) {
replaceBookmarkFileInsertion(builder, bookmark);
}
}
}
}
private static void replaceBookmarkFileInsertion(DocumentBuilder builder, Bookmark bookmark) throws Exception {
String bookmarkValue = bookmark.getText();
String url = getUrl(bookmarkValue);
if (url != null) {
builder.moveTo(bookmark.getBookmarkStart());
try {
Document docx = new Document(new File(url).getAbsolutePath());
Node insertAfter = (Node) insertDocument(builder.getCurrentParagraph(), docx);
builder.moveTo(insertAfter);
} catch (UnsupportedFileFormatException e) {
}
bookmark.setText("");
// bookmark.remove();
}
}
(See the file ‘TestInsertV2.txt’ is my JAVA code).
But with this code, the heading are not correctly re numbered. (See output2.docx)
I can not use the method : builder.moveToDocumentEnd() because I can have to insert the file in the bookmark location.
Sorry if you do not still understand, please tell me, that I try to explain more clearly.
Thanks in advance.
Regards
Hi Roseline,
Thanks for sharing the information. I have tested the scenario at my side again and have found any issue with output file. Please find the output document in attachment and let us know if there is any issue with output document.
It would be great if you please mark the text with wrong headings and share the document with us.
Hi,
Sorry for the file.
I try to attach the good result and the highlight section which has the problem.
Regards.
Hi Roseline,
Thanks for sharing the document. I have tested the scenario and have managed to reproduce this issue at my side. I have logged this issue as WORDSNET-6581 in our issue tracking system. You will be notified via this forum thread once this issue is resolved.
We apologize for your inconvenience.
Hi
Thanks for your request. I think the following article might be useful for you:
https://docs.aspose.com/words/net/working-with-lists/
Best regards,
Hi Alexey,
Thank you for your link.
In the example, I wish to be in the 2nd example which that the merge of the ‘NordthWind Trader’ list and the ‘Beverages’ list has continous numbered, so as explain in the document, we have to use the option ‘ImportFormat.UseDestinationStyles’, but it does not work in my code…
Perhaps I miss something…
Hi Roseline,
Thanks for your query. Yes, the example you are using is not working with your documents. We will update you via this forum thread once this issue is resolved.
We apologize for your inconvenience.
Hi,
Is there any news about this issue ?
Regards.
Hi Roseline,
Thanks for your patience.
I am afraid this issue WORDSNET-6581 has now been postponed till a later date due to some other important issues and new features. We will inform you as soon as there are any further developments.
We apologize for your inconvenience.
The issues you have found earlier (filed as WORDSNET-6581) have been fixed in this Aspose.Words for .NET 18.3 update and this Aspose.Words for Java 18.3 update.