当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.MoveToBookmark方法代码示例

本文整理汇总了C#中DocumentBuilder.MoveToBookmark方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.MoveToBookmark方法的具体用法?C# DocumentBuilder.MoveToBookmark怎么用?C# DocumentBuilder.MoveToBookmark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.MoveToBookmark方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DocumentBuilderMoveToBookmark

        public void DocumentBuilderMoveToBookmark()
        {
            //ExStart
            //ExId:DocumentBuilderMoveToBookmark
            //ExSummary:Shows how to move a cursor position to a bookmark.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToBookmark("CoolBookmark");
            builder.Writeln("This is a very cool bookmark.");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:12,代码来源:ExDocumentBuilder.cs

示例2: DocumentBuilderMoveToBookmarkEnd

        public void DocumentBuilderMoveToBookmarkEnd()
        {
            //ExStart
            //ExFor:DocumentBuilder.MoveToBookmark(String, Boolean, Boolean)
            //ExId:DocumentBuilderMoveToBookmarkEnd
            //ExSummary:Shows how to move a cursor position to just after the bookmark end.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToBookmark("CoolBookmark", false, true);
            builder.Writeln("This is a very cool bookmark.");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:13,代码来源:ExDocumentBuilder.cs

示例3: WorkingWithNodes

        public void WorkingWithNodes()
        {
            //ExStart
            //ExFor:DocumentBuilder.MoveTo(Node)
            //ExFor:DocumentBuilder.MoveToBookmark(String)
            //ExFor:DocumentBuilder.CurrentParagraph
            //ExFor:DocumentBuilder.CurrentNode
            //ExFor:DocumentBuilder.MoveToDocumentStart
            //ExFor:DocumentBuilder.MoveToDocumentEnd
            //ExSummary:Shows how to move between nodes and manipulate current ones.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.WorkingWithNodes.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Move to a bookmark and delete the parent paragraph.
            builder.MoveToBookmark("ParaToDelete");
            builder.CurrentParagraph.Remove();

            // Move to a particular paragraph's run and replace all occurrences of "bad" with "good" within this run.
            builder.MoveTo(doc.LastSection.Body.Paragraphs[0].Runs[0]);
            builder.CurrentNode.Range.Replace("bad", "good", false, true);

            // Mark the beginning of the document.
            builder.MoveToDocumentStart();
            builder.Writeln("Start of document.");

            // Mark the ending of the document.
            builder.MoveToDocumentEnd();
            builder.Writeln("End of document.");

            doc.Save(ExDir + "DocumentBuilder.WorkingWithNodes Out.doc");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:32,代码来源:ExDocumentBuilder.cs

示例4: MoveToBookmarkEnd

        public static void MoveToBookmarkEnd(string dataDir)
        {
            // ExStart:DocumentBuilderMoveToBookmarkEnd
            Document doc = new Document(dataDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToBookmark("CoolBookmark", false, true);
            builder.Writeln("This is a very cool bookmark.");
            // ExEnd:DocumentBuilderMoveToBookmarkEnd              
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:10,代码来源:DocumentBuilderMovingCursor.cs

示例5: GenerateBodyDoc

        /// <summary>
        /// Function to generate the Body Document.
        /// </summary>
        /// <param name="bodyTemplate"></param>
        /// <param name="schedule"></param>
        /// <param name="notice1"></param>
        /// <param name="recommendation"></param>
        /// <param name="natureOfAdvice"></param>
        /// <param name="documentValues"></param>
        /// <param name="draft"></param>
        /// <param name="saveFormat"></param>
        /// <returns></returns>
        public static byte[] GenerateBodyDoc(byte[] bodyTemplate, byte[] schedule, byte[] notice1, byte[] recommendation, byte[] natureOfAdvice,
            Tuple<Dictionary<string, string>, Dictionary<string, string[,]>> documentValues, bool draft, SaveFormat saveFormat)
        {
            Dictionary<string, string> docValues = documentValues.Item1;
            Dictionary<string, string[,]> docArrayValues = documentValues.Item2;

            MemoryStream newStream = null;
            if (bodyTemplate != null)
            {
                newStream = new MemoryStream(bodyTemplate);
            }

            // Read the document from the stream.
            Document doc = new Document(newStream);

            for (int index = 0; index < doc.Range.Bookmarks.Count; index++)
            {
                Bookmark bookmark = doc.Range.Bookmarks[index];
                string bookmarkName = bookmark.Name;
                if (
                            bookmarkName.StartsWith("ai_", true, CultureInfo.CurrentCulture)
                            || bookmarkName.StartsWith("ae_", true, CultureInfo.CurrentCulture)
                            || bookmarkName.StartsWith("ab_", true, CultureInfo.CurrentCulture)
                            )
                {
                    bookmarkName = bookmarkName.Substring(3);
                }

                string caseCorrectKey;
                if (TryGetKeyWithCorrectCase(docValues.Keys, bookmarkName, out caseCorrectKey) && bookmarkName != Bookmarks.POL_PARTICULARS)  //if (docValues.ContainsKey(bookmarkName) && bookmarkName != "pol_particulars")
                {
                    string suffix = "";
                    string tempValue;
                    if (docValues[caseCorrectKey] != "" && (bookmark.Text.EndsWith("\r") || bookmark.Text.EndsWith("\r\n")))
                    {
                        suffix = Environment.NewLine;
                    }

                    try
                    {
                        tempValue = docValues[caseCorrectKey] ?? "" + suffix;

                        if (String.IsNullOrWhiteSpace(bookmark.Text))
                        {
                            bookmark.Text = tempValue;
                        }
                    }
                    catch (Exception e)
                    {
                        string temp = e.Message;
                        bookmark.Remove();
                    }
                }

                string correctKey;
                if (TryGetKeyWithCorrectCase(docArrayValues.Keys, bookmarkName, out correctKey) && bookmarkName != Bookmarks.POL_PARTICULARS) //(docArrayValues.ContainsKey(bookmarkName) && bookmarkName != "pol_particulars")
                {
                    if (((Paragraph)bookmark.BookmarkStart.ParentNode).ParentNode.NodeType == NodeType.Cell)
                    {
                        DocumentBuilder builder = new DocumentBuilder(doc);
                        builder.MoveToBookmark(bookmark.Name);
                        Cell currentCell = (Cell)builder.CurrentParagraph.GetAncestor(NodeType.Cell);

                        string[,] data = docArrayValues[correctKey];

                        for (int rowIndex = 0; rowIndex <= data.GetUpperBound(0); rowIndex++)
                        {
                            for (int colIndex = 0; colIndex <= data.GetUpperBound(1); colIndex++)
                            {
                                if (data[rowIndex, colIndex] != null)
                                {
                                    builder.Write(data[rowIndex, colIndex]);
                                    if (!(rowIndex == data.GetUpperBound(0) && colIndex == data.GetUpperBound(1)))
                                    {
                                        currentCell = MoveToNextCell(builder, currentCell);
                                    }
                                }
                                else
                                {
                                    if (!(rowIndex == data.GetUpperBound(0) && colIndex == data.GetUpperBound(1)))
                                    {
                                        currentCell = MoveToNextCell(builder, currentCell);
                                    }
                                }
                            }
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:khangtran-steadfast,项目名称:DatabaseConversion,代码行数:101,代码来源:WordGenerator.cs

示例6: InsertImage

 public static void InsertImage(Document mainDoc,string bookmarkName, string path)
 {
     DocumentBuilder builder = new DocumentBuilder(mainDoc);
     if (mainDoc.Range.Bookmarks[bookmarkName] != null)
     {
         mainDoc.Range.Bookmarks[bookmarkName].Text = "";
     }
     builder.MoveToBookmark(bookmarkName);
     builder.InsertImage(path);
 }
开发者ID:khangtran-steadfast,项目名称:DatabaseConversion,代码行数:10,代码来源:WordGenerator.cs

示例7: InsertBlockAtBookamrk

        public static void InsertBlockAtBookamrk(Document brokerPlusDot, string bookmarkName, Document MainDoc, int type)
        {
            BuildingBlock block = null;
            string bmark = type == 0 ? bookmarkName.ToUpper() : (bookmarkName.ToUpper() + "_" + type.ToString());

                foreach (BuildingBlock b in brokerPlusDot.GlossaryDocument.BuildingBlocks)
                {
                    if (b.Name.ToUpper() == bmark)
                    {
                        block = b;
                        break;
                    }
                }
                       //Create DocumentBuilder
            DocumentBuilder builder = new DocumentBuilder(MainDoc);
            //Move cursor to bookmark and insert paragraph break
            if (!builder.MoveToBookmark(bookmarkName, false, true) || block == null)
            {
                return;
            }
            //builder.MoveToBookmark(bookmarkName);
            builder.Writeln();
            //Content of srcdoc will be inserted after this node
            Node insertAfterNode = builder.CurrentParagraph.PreviousSibling;
            //Content of first paragraph of srcDoc will be apended to this parafraph
            Paragraph insertAfterParagraph = (Paragraph)insertAfterNode;
            //Content of last paragraph of srcDoc will be apended to this parafraph
            Paragraph insertBeforeParagraph = builder.CurrentParagraph;
            //We will be inserting into the parent of the destination paragraph.
            CompositeNode dstStory = insertAfterNode.ParentNode;

            //Get list if current paragraph is list item
            List list = null;
            Color listFontColor = Color.Black;
            if (insertAfterParagraph.IsListItem)
            {
                list = insertAfterParagraph.ListFormat.List;
                listFontColor = insertAfterParagraph.ListFormat.ListLevel.Font.Color;
            }
            //Loop through all sections in the source document.
            foreach (Section srcSection in block.Sections)
            {
                //Loop through all block level nodes (paragraphs and tables) in the body of the section.
                foreach (Node srcNode in srcSection.Body)
                {
                    //Do not insert node if it is a last empty paragarph in the section.
                    Paragraph para = srcNode as Paragraph;

                    //If current paragraph is first paragraph of srcDoc
                    //then appent its content to insertAfterParagraph
                    if (para != null && (para.Equals(block.FirstSection.Body.FirstParagraph)))
                    {
                        Paragraph dstParagraph = (Paragraph)MainDoc.ImportNode(para, true, ImportFormatMode.KeepSourceFormatting);
                        while (dstParagraph.HasChildNodes)
                        {
                            //Node dstNode = MainDoc.ImportNode(node, true, ImportFormatMode.KeepSourceFormatting);
                            insertAfterParagraph.AppendChild(dstParagraph.FirstChild);
                        }

                        if (!insertAfterParagraph.IsListItem && dstParagraph.IsListItem)
                        {
                            if (list == null)
                            {
                                list = dstParagraph.ListFormat.List;
                            }
                            insertAfterParagraph.ListFormat.List = list;
                            listFontColor = para.ListFormat.ListLevel.Font.Color;

                        }
                        //If subdocument contains only one paragraph
                        //then copy content of insertBeforeParagraph to insertAfterParagraph
                        //and remove insertBeforeParagraph
                        if ((block.FirstSection.Body.FirstParagraph.Equals(block.LastSection.Body.LastParagraph)))
                        {
                            while ((insertBeforeParagraph.HasChildNodes))
                            {
                                insertAfterParagraph.AppendChild(insertBeforeParagraph.FirstChild);
                            }
                            insertBeforeParagraph.Remove();
                        }
                    }
                    //If current paragraph is last paragraph of srcDoc
                    //then appent its content to insertBeforeParagraph
                    else if (para != null && (para.Equals(block.LastSection.Body.LastParagraph)))
                    {
                        Node tofix;
                        Node previouseNode = null;
                        foreach (Node node in para.ChildNodes)
                        {
                            Node dstNode = MainDoc.ImportNode(node, true, ImportFormatMode.KeepSourceFormatting);
                            if ((previouseNode == null))
                            {
                                //insertBeforeParagraph.InsertBefore(dstNode, insertBeforeParagraph.FirstChild);
                                tofix = insertBeforeParagraph.InsertBefore(dstNode, insertBeforeParagraph.FirstChild);
                            }
                            else
                            {
                                //insertBeforeParagraph.InsertAfter(dstNode, previouseNode);
                                tofix = insertBeforeParagraph.InsertAfter(dstNode, previouseNode);
                            }
//.........这里部分代码省略.........
开发者ID:khangtran-steadfast,项目名称:DatabaseConversion,代码行数:101,代码来源:WordGenerator.cs


注:本文中的DocumentBuilder.MoveToBookmark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。