Hi Team,
I met the issue as title mentioned.
The code snippet is a simulation of the issue from our codebase. I can reproduce it on my side.
public static void main(String[] args) throws Exception {
Document firstDoc = new Document("C:\\User\\report_to_add_Part I.docx");
Document secondDoc = new Document("C:\\User\\report_to_add_Part II.docx");
for (int i = 0; i < secondDoc.getSections().getCount(); i++) {
// First need to import the section into the destination document,
// this applies the destination lists and styles to the imported section
Section sectionToImport =
(Section) firstDoc.importNode(secondDoc.getSections().get(i), true, ImportFormatMode.USE_DESTINATION_STYLES);
// Append the section to import to the last section
firstDoc.getLastSection().appendContent(sectionToImport);
}
firstDoc.save("output.docx", SaveOptions.createSaveOptions(SaveFormat.DOCX));
}
Pls help check this issue. I’m using 22.2 with formal license, but I can reproduce on 25.2 with a trial. I also tried to use KEEP_SOURCE_FORMATTING import mode, not worked.
Document firstDoc = new Document("C:\\Temp\\report_to_add_Part I.docx");
Document secondDoc = new Document("C:\\Temp\\report_to_add_Part II.docx");
ImportFormatOptions opt = new ImportFormatOptions();
opt.setKeepSourceNumbering(true);
NodeImporter importer = new NodeImporter(secondDoc, firstDoc, ImportFormatMode.USE_DESTINATION_STYLES, opt);
for (int i = 0; i < secondDoc.getSections().getCount(); i++)
{
// First need to import the section into the destination document,
// this applies the destination lists and styles to the imported section
Section sectionToImport = (Section)importer.importNode(secondDoc.getSections().get(i), true);
// Append the section to import to the last section
firstDoc.getLastSection().appendContent(sectionToImport);
}
firstDoc.save("C:\\Temp\\out.docx");
BTW, I want to know this KeepSourceNumbering option is a change in a version update, right? In my previous version of application, using Aspose 14.11, quite an old version, I don’t need to add this configuration and it worked at that time.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.