zoukankan      html  css  js  c++  java
  • Aspose.Words CookieBook

    Aspose.Words.dll  版本 13.1.0.0

    【原创】Aspose.Words组件介绍及使用—基本介绍与DOM概述

    插入分页符

    DocumentBuilder builder = new DocumentBuilder(Document);
    Bookmark bookmark = parentWH.Document.Range.Bookmarks[bookMark];
    builder.MoveTo(bookmark.BookmarkEnd.ParentNode);
    builder.InsertBreak(BreakType.PageBreak);

     在文档末尾插入自定义书签

    builder.MoveTo(wh.Document.FirstSection.Body.LastParagraph);
    builder.StartBookmark(BookmarkFlag + OrderNum);
    builder.EndBookmark(BookmarkFlag + OrderNum);

     合并文档(不同word文档的合并成一个Word文档)

     1 Document dstDoc = null;
     2 for (int i = 0; i < Paths.Count; i++)
     3 {
     4     Document srcDoc = null;
     5     if (i == 0)
     6     {
     7         dstDoc = new Document(Paths[i]);
     8     }
     9     else
    10     {
    11         srcDoc = new Document(Paths[i]);
    12     }
    13     if (srcDoc != null)
    14     {
    15         //Make the document appear straight after the destination documents content.
    16         srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
    17         dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
    18     }
    19 }
    20 dstDoc.Save(CompletePath, SaveFormat.Docx);//持久化

    16行效果去掉合并时的分页效果,如果去掉此行,合并的文档单独起始一页.

     更多实例 https://docs.aspose.com/display/wordsnet/Open+and+Add+text+to+Word+Document  注意页面下部

    找到Word全部的书签Bookmarks

    File.Copy(FromPath, ToPath);
    wh.LoadWordDocument(ToPath);
    try
    {
        //获取一份文档的全部书签
        IEnumerator allBookmarks  = wh.Document.Range.Bookmarks.GetEnumerator(); //Document是Aspose.Words.Document,wh是我自己封装的一个类WordPlayAspose的对象
        while (allBookmarks.MoveNext())
        {
            //然后根据 bookmarkName找到某一个书签  Crop_Name
            Bookmark bookMark = (Bookmark)allBookmarks.Current;
            if (bookMark.Name.Equals("Crop_Name", StringComparison.CurrentCultureIgnoreCase))
            {
                bookMark.Text = "找到了1";
            }
            else if (bookMark.Name.Equals("TN_1", StringComparison.CurrentCultureIgnoreCase))
            {
                bookMark.Text = "找到了2";
            }
        }
        //....  

    //很好的参考
    https://apireference.aspose.com/net/words/aspose.words/compositenode/methods/index
    https://www.cnblogs.com/EllisQian/archive/2017/04/29/6784688.html 

  • 相关阅读:
    mysql之drop、truncate和delete的区别
    mysql之表结构,表空间,段,区,页,MVCC(待整理)
    mysql之子查询、视图、事务及pymysql等
    mysql之单表查询、多表查询
    解决跨域问题!
    项目--2
    项目--1
    后端接口书写
    VUE-组件
    VUE基本写法
  • 原文地址:https://www.cnblogs.com/zhuji/p/6251988.html
Copyright © 2011-2022 走看看