背景

这个是一个操作word文档的插件

1.1插入图片

using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Rendering;   Document doc = new Document(TempValue);//TempValue doc模板的路径   DocumentBuilder builder = new DocumentBuilder(doc);   Shape shape = new Shape(doc,ShapeType.Image);   shape.ImageData.SetImage(Server.MapPath("Images/test.jpg"));   shape.Width = 70;//设置宽和高
  shape.Height = 70;   shape.WrapType = WrapType.None;
  shape.BehindText = true;   //shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
  //shape.HorizontalAlignment = HorizontalAlignment.Center;
  //shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
  //shape.VerticalAlignment = VerticalAlignment.Center;
  //shape.HorizontalAlignment = HorizontalAlignment.Center;   builder.MoveToBookmark("PO_MyImage");
  builder.InsertNode(shape);   doc.Save("newword.doc",SaveFormat.Doc);

1.2删除指定段落

// 根据表格找到所在段落
var paragraph = (Paragraph) table.GetAncestor(NodeType.Paragraph);
// 清除段落前的分页符
if (paragraph.ParagraphFormat.PageBreakBefore)
paragraph.ParagraphFormat.PageBreakBefore = false;
// 清除段落中的分页符
foreach (Run run in paragraph.Runs)
{
if (run.Text.Contains(ControlChar.PageBreak))
run.Text = run.Text.Replace(ControlChar.PageBreak, string.Empty);
}

1.3合并文档

Document doc = new Document();
// We should call this method to clear this document of any existing content.
doc.RemoveAllChildren(); int recordCount = 5;
for (int i = 1; i <= recordCount; i++)
{
// Open the document to join.
Document srcDoc = new Document(@"C:\DetailsList.doc"); // Append the source document at the end of the destination document.
doc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles); // In automation you were required to insert a new section break at this point, however in Aspose.Words we
// don't need to do anything here as the appended document is imported as separate sectons already. // If this is the second document or above being appended then unlink all headers footers in this section
// from the headers and footers of the previous section.
if (i > 1)
doc.Sections[i].HeadersFooters.LinkToPrevious(false);
}

1.4合并的时候在同一页显示

Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
Document srcDoc = new Document(gDataDir + "TestFile.Source.doc"); // Make the document appear straight after the destination documents content.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous; // Append the source document using the original styles found in the source document.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.Save(gDataDir + "TestFile.JoinContinuous Out.doc");

1.5合并的时候再另外一页开始

 Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
Document srcDoc = new Document(gDataDir + "TestFile.Source.doc"); // Set the appended document to start on a new page.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage; // Append the source document using the original styles found in the source document.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.Save(gDataDir + "TestFile.JoinNewPage Out.doc");

1.6其他的一些信息

https://blog.csdn.net/ibigpig/article/details/8432245

1.7 Spire.Doc与Aspose.Words功能对比

http://www.cnblogs.com/dare/archive/2018/07/03/9259417.html

c# aspose操作word文档的更多相关文章

  1. iText操作word文档总结

    操作word文档的工具有很多,除了iText之外还有POI,但是POI擅长的功能是操作excel,虽然也可以操作word,但是能力有限,而且还有很多的bug,技术并不成熟,下面就重点介绍一种操作wor ...

  2. C#操作Word文档(加密、解密、对应书签插入分页符)

    原文:C#操作Word文档(加密.解密.对应书签插入分页符) 最近做一个项目,客户要求对已经生成好的RTF文件中的内容进行分页显示,由于之前对这方面没有什么了解,后来在网上也找了相关的资料,并结合自己 ...

  3. 利用Python操作Word文档【图片】

    利用Python操作Word文档

  4. Java文件操作系列[3]——使用jacob操作word文档

    Java对word文档的操作需要通过第三方组件实现,例如jacob.iText.POI和java2word等.jacob组件的功能最强大,可以操作word,Excel等格式的文件.该组件调用的的是操作 ...

  5. QTP操作word文档

    QTP可以对word文档进行操作,这里最主要展示的是向word文档写入内容,并保存的功能. Option explicit Dim wordApp Set wordApp = createobject ...

  6. c#中操作word文档-四、对象模型

    转自:http://blog.csdn.net/ruby97/article/details/7406806 Word对象模型  (.Net Perspective) 本文主要针对在Visual St ...

  7. python 操作word文档

    因为工作需要操作一些word文档,记录一下学习思路 #-*- encoding: utf8 -*- import win32com from win32com.client import Dispat ...

  8. 2.QT中操作word文档

     Qt/Windows桌面版提供了ActiveQt框架,用以为Qt和ActiveX提供完美结合.ActiveQt由两个模块组成: A   QAxContainer模块允许我们使用COM对象并且可以 ...

  9. C# 操作Word 文档——添加Word页眉、页脚和页码

    在Word文档中,我们可以通过添加页眉.页脚的方式来丰富文档内容.添加页眉.页脚时,可以添加时间.日期.文档标题,文档引用信息.页码.内容解释.图片/LOGO等多种图文信息.同时也可根据需要调整文字或 ...

  10. Java操作word文档使用JACOB和POI操作word,Excel,PPT需要的jar包

    可参考文档: http://wibiline.iteye.com/blog/1725492 下载jar包 http://download.csdn.net/download/javashixiaofe ...

随机推荐

  1. docker 部署prometheus和grafana

    prometheus(普罗米修斯):天生为采集存储监控数据而生的时序数据库.prometheus通过各种Exporter采集到监控数据,然后存储进prometheus中,以供查询展示. grafana ...

  2. HttpClientHandler VS SocketsHttpHandler

    .NET Framework 和 .NET Core 2.0 及更低版本中由 HttpClient 使用的默认消息处理程序为HttpClientHandler. 从 .NET Core 2.1 开始, ...

  3. stm32芯片的SPI接口调试总结之轮询模式

    一 概念 1 组成 SPI系统可直接与各个厂家生产的多种标准外围器件接口,它只需4条线:串行时钟线(SCK).主机输入/从机输出数据线(MISO).主机输出/从机输入数据线(MOSI)和低电平有效的从 ...

  4. ubuntu中在命令行如何打开图形界面的文件夹的几种方法

    方法一: 使用自带的命令:nautilus . 打开当前文件夹 nautilus . 打开指定路径文件夹 nautilus ddd/ccc/ 方法二:xdg-open xdg-open 命令相当于在 ...

  5. html添加css样式的两种方法

      html添加css样式有三种方法,分别为行内式(使用style属性,在特定的HTML标签内使用).内嵌式(style标签把css代码放在特定页面的head部分中).外联式(使用link标签,将外部 ...

  6. Eclipse之各个版本的区别

    经常用到的是前五个版本: Eclipse IDE for Java EE Developers:是为J2EE开发的版本: Eclipse Classic:是Eclipse的经典版本,没有安装任何插件, ...

  7. CMake 用法总结(转载)

    原文地址 什么是 CMake All problems in computer science can be solved by another level of indirection. David ...

  8. HISI3520DV300 折腾记录(一)之 《Uboot-Start.S分析 以及 相关启动流程分析》

    PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明   本文作为本人csdn blog的主站的备份.(Bl ...

  9. uni组件传值注意

    目录介绍 01.组件传值遇到坑 02.父组件传值给子组件 03.子组件传值给父组件 01.组件传值遇到坑 子组件给父组件传值注意点 注意子组件触发事件定义的方法,首先在父组件中需要绑定子组件内部对应事 ...

  10. 【Leetcode】300. 最长递增子序列

    题目(链接) 给你一个整数数组nums,找到其中最长严格递增子序列的长度. 子序列是由数组派生而来的序列,删除(或不删除)数组中的元素而不改变其余元素的顺序.例如,[3,6,2,7]是数组[0,3,1 ...