将 Word 文档合并为单个文档
我使用下面提到的链接中的代码将word文件合并到单个文件
但是,看到输出文件,我意识到它无法复制第一个文档中的标题图像。我们如何合并保留格式和内容的文档。
I used the code in the link mentioned below to merge word files into a single file
However, seeing the output file i realized that it was unable to copy header image in the first document. How do we merge documents preserving format and content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议使用 GroupDocs.Merger Cloud 用于将多个Word文档合并为单个Word文档,它保留源文档的格式和内容。它是一个独立于平台的REST API解决方案,不依赖于任何第三方工具或软件。
C# 代码示例:
I will suggest to use GroupDocs.Merger Cloud for merging multiple word document to a single word document, it keeps the formatting and contents of the source documents. It is a platform independent REST API solution without depending on any third-party tool or software.
Sample C# code:
该代码在每个文件后插入一个分页符。
由于节控制标题,如果第二个或后续文档有标题,您可能希望保留原始节属性,并将它们插入到第一个文档之后。
如果您将原始文档视为 docx,您可能会发现您的部分是文档级部分属性元素。
解决问题的最简单方法可能是在最后一段(其中包含标题信息)内创建第二个部分属性元素。然后,当文档合并时,这应该保留在那里(即在其后添加其他段落)。
这就是理论。另请参阅http://www.pcreview.co.uk/forums/thread-898133 .php
但我还没有尝试过;它假设 InsertFile 的行为符合我的预期。
That code is inserting a page break after each file.
Since sections control headers, if a second or subsequent document has a header, you'll probably be wanting to keep the original section properties, and insert those after your first document.
If you look at your original document as a docx, you'll probably see that your section is a document level section properties element.
The easiest way around your problem may be to create a second section properties element inside the last paragraph (which contains the header information). Then this should just stay there when the documents are merged (ie other paragraphs added after it).
That's the theory. See also http://www.pcreview.co.uk/forums/thread-898133.php
But I haven't tried it; it assumes InsertFile behaves as I expect it should.
我需要做同样的事情,我的方法,无需编码的最简单方法是:
在Mac中:
对于 Windows:
I needed to do the same, my approach, easiest way without coding is:
In Mac:
For windows: