我以前做过类似的项目  但是我们做的是将word转成一个个pdf   然后合并pdf的   不知道你需要吗?  需要的话我帮你找找源码

解决方案 »

  1.   

    这个应该是更好的思路。
    如果不是代码实现的话,都是使用Adobe Acrobat X 进行word和pdf互相转换,并实现pdf合并的。
    代码实现,可能也可以使用Adobe Acrobat X 提供的库。
      

  2.   

    这个应该是更好的思路。
    如果不是代码实现的话,都是使用Adobe Acrobat X 进行word和pdf互相转换,并实现pdf合并的。
    代码实现,可能也可以使用Adobe Acrobat X 提供的库。
    谢谢夸奖  嘿嘿
      

  3.   

    如果是企业项目,可以使用三方组件aspose.total(支持word、excel、ppt、pdf...操作及相互转换)
      

  4.   

    合并文档很简单,例如(随手写的,可能有语法错误,看懂意思就好):        private static void Start(FileInfo[] Files)
            {
                var app = new word.Application();
                var doc = app.Documents.Add();
                forea(var d in files)
                 {
                         app.Selection.InsertFile(d.FullName);
                         app.Selection.InsertBreak(word.WdBreakType.wdPageBreak);
                 };
                doc.SaveAs2(FileName: Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "合并结果.docx"));
                doc.Close();
                app.Quit();
            }输出pdf,这也是上述doc的固有的SaveAs功能中的一项。这里就不给你写了。如果要进行比较专业的Office二次开发(而不是极其简单的个别操作),希望你好好研习Office的官方的组件和对象的使用方法,先不去纠结什么“第三方”组件。
      

  5.   

    forea  -->  foreach这种程序成文自明。它依次插入一个文件,然后插入换页。Office的对象和方法,很简单、很“傻瓜”。其实越是这种非常“草根”的官方 api 越是多年成熟的标志。
      

  6.   

    这种东西也很容易编写。你只要在 Word 菜单上“录制宏”,然后操作,人家 Office 就给你自动编写出来宏代码来了。然后你可以精炼一下,把 VBA 代码手工翻译为 c# 代码。就是上面这样的代码。
      

  7.   

    把多个Word文档合并到一个Word文档示例
    //选择合并文档的保存位置开始合并Word文档
    private Word.Application G_wa;//定义Word应用程序
            private object G_missing = //定义G_missing字段并添加引用
                System.Reflection.Missing.Value;
            private OpenFileDialog G_OpenFileDialog;//定义打开文件对话框
            private SaveFileDialog G_SaveFileDialog;//定义保存文件对话框
            private List<string> G_Str_Files = new List<string>();//定义字符串集合        private void btn_split_Click(object sender, EventArgs e)
            {
                btn_Merge.Enabled = false;//停用合并按钮
                ThreadPool.QueueUserWorkItem(//开始线程池
                    (pp) =>//使用lambda表达式
                    {
                        G_wa = new Microsoft.Office.Interop.Word.Application();//创建应用程序对象
                        Word.Document P_MainDocument =//新建合并文档对象
                            G_wa.Documents.Add(ref G_missing, ref G_missing
                            , ref G_missing, ref G_missing);
                        foreach (string P_Str in G_Str_Files)//遍历文档的集合
                        {
                            object P_strs = P_Str;//创建object对象
                            Word.Document P_Document = G_wa.Documents.Open(//打开Word文档
                                ref P_strs, ref G_missing, ref G_missing, ref G_missing
                                , ref G_missing, ref G_missing, ref G_missing, ref G_missing
                                , ref G_missing, ref G_missing, ref G_missing, ref G_missing
                                , ref G_missing, ref G_missing, ref G_missing, ref o);
                            Word.Range P_Range_temp = //得到文档全部范围
                                P_Document.Range(ref G_missing, ref G_missing);
                            P_Range_temp.Select();//选择文档全部范围
                            P_Range_temp.Copy();//复制文档全部范围
                            Word.Range P_Range_temp2 =//得到文档的范围
                                P_MainDocument.Range(ref G_missing, ref G_missing);
                            object P_end= Word.WdCollapseDirection.wdCollapseEnd;//创建object对象
                            P_Range_temp2.Collapse(ref P_end);//折叠文档范围
                            P_Range_temp2.Select();//选择档的最后位置
                            P_Range_temp2.Paste();//粘贴文档内容
                            ((Word._Document)P_Document).Close(ref G_missing, ref G_missing,//关闭文档
                                ref G_missing);
                        }
                        object P_SavePath=G_SaveFileDialog.FileName;//创建object对象
                        P_MainDocument.SaveAs(//保存合并后的文档
                            ref P_SavePath, ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                            ref G_missing, ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                            ref G_missing, ref G_missing, ref G_missing, ref G_missing, ref G_missing,
                            ref G_missing);//CodeGo.net/
                        ((Word._Application)G_wa.Application).Quit(//退出应用程序
                            ref G_missing, ref G_missing, ref G_missing);
                        this.Invoke(//调用窗体线程
                            (MethodInvoker)(() =>//使用lambda表达式
                            {
                                Clipboard.Clear();//清空剪切板
                                MessageBox.Show(//提示已经创建Word
                                    "成功合并Word文档!", "提示!");
                                btn_Merge.Enabled = true;//启用合并按钮
                            }));
                    });
            }
    //创建文件对话框对象
    private void txt_select_Click(object sender, EventArgs e)
            {
                G_OpenFileDialog
                    = new OpenFileDialog();
                G_OpenFileDialog.Filter = //筛选文件
                    "*.doc|*.doc";
                DialogResult P_DialogResult =//打开文件对话框
                    G_OpenFileDialog.ShowDialog();
                if (P_DialogResult == DialogResult.OK)//确认已经选择文件
                {
                    lb_FileCollection.Items.Add(G_OpenFileDialog.FileName);
                    G_Str_Files.Add(G_OpenFileDialog.FileName);
                    btn_Save.Enabled = true;
                    txt_path.Text = //显示将要打开的文件
                        G_OpenFileDialog.FileName;
                }
            }
    //创建保存文件对话框对象
    private void btn_Save_Click(object sender, EventArgs e)
            {
                G_SaveFileDialog = 
                    new SaveFileDialog();
                G_SaveFileDialog.Filter = "*.doc|*.doc";
                DialogResult P_DialogResult = //打开保存文件对话框
                    G_SaveFileDialog.ShowDialog();
                if (P_DialogResult == DialogResult.OK)//判断是否保存文件
                {
                    btn_Merge.Enabled = true;//启用合并按钮
                    txt_SavePath.Text = //显示保存文件路径
                        G_SaveFileDialog.FileName;
                }
            }
      

  8.   

    比较简单的方法:
     //Load two documents
    //Load Document1 and Document2
    Document DocOne = new Document();
    DocOne.LoadFromFile(@"E:\Work\Document\welcome.docx", FileFormat.Docx);
    Document DocTwo = new Document();
    DocTwo.LoadFromFile(@"E:\Work\Document\New Zealand.docx", FileFormat.Docx);
     
    //Merge
    foreach (Section sec in DocTwo.Sections)
    {
     DocOne.Sections.Add(sec.Clone());
    }
    //Save and Launch
    DocOne.SaveToFile("Merge.docx", FileFormat.Docx);详细参考: http://blog.csdn.net/eiceblue/article/details/43668671