Aspose:带有 USE_DESTINATION_STYLES 的 InsertDocument 不起作用

问题描述

我正在尝试使用带有 ImportFormatMode.USE_DESTINATION_STYLES 选项的文档构建器对象将源文档插入到目标文档中。 (见下面的代码片段)

public static void main(String[] args) throws Exception {
    Document destDoc = new Document("/home/cipet/Downloads/destDoc.docx");
    Document srcDoc = new Document("/home/cipet/Downloads/srcDoc.docx");
    DocumentBuilder documentBuilder = new DocumentBuilder(destDoc);
    documentBuilder.insertDocument(srcDoc,ImportFormatMode.USE_DESTINATION_STYLES);
    documentBuilder.getDocument().save("/home/cipet/Downloads/final.docx");
}

但是最终的文档没有以预期的输出生成。 请让我知道使用目标文档样式生成最终文档的解决方案是什么。

有关更多详细信息,我已在 aspose 论坛中附上了源、目标和预期输出 https://forum.aspose.com/t/insertdocument-with-use-destination-styles-not-working/227548

谢谢

解决方法

当您使用 ImportFormatmode.USE_DESTINATION_STYLES 时,将使用目标文档中的样式。例如,如果您的源文档中的段落具有 Heading1 样式,则在将其插入目标文档后,将使用目标文档中的 Heading1 样式。

实际上并不清楚您的预期输出是什么,因此我建议您在相应的 forum 中提出问题并附上您的源、目标、输出和预期输出文档。