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


C# DocumentBuilder.MoveToDocumentEnd方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }
            Document doc = new Document("../../data/document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            //Shows how to access the current node in a document builder.
            Node curNode = builder.CurrentNode;
            Paragraph curParagraph = builder.CurrentParagraph;

            // Shows how to move a cursor position to a specified node.
            builder.MoveTo(doc.FirstSection.Body.LastParagraph);

            // Shows how to move a cursor position to the beginning or end of a document.
            builder.MoveToDocumentEnd();
            builder.Writeln("This is the end of the document.");

            builder.MoveToDocumentStart();
            builder.Writeln("This is the beginning of the document.");

            doc.Save("outputDocument.doc");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:30,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\..\Sample Files\";
            string File = FilePath + "Create and add a paragraph style - Aspose.docx";
            
            // Open the new document.
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);
            // Set font formatting properties
            Aspose.Words.Font font = builder.Font;
            font.Bold = true;
            font.Color = System.Drawing.Color.Red;
            font.Italic = true;
            font.Name = "Arial";
            font.Size = 24;
            font.Spacing = 5;
            font.Underline = Underline.Double;

            // Output formatted text
            builder.MoveToDocumentEnd();
            builder.Writeln("I'm a very nice formatted string.");

            string txt = builder.CurrentParagraph.GetText();

            doc.Save(File);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:27,代码来源:Program.cs

示例3: MoveToDocumentStartEnd

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

            builder.MoveToDocumentEnd();
            Console.WriteLine("\nThis is the end of the document.");

            builder.MoveToDocumentStart();
            Console.WriteLine("\nThis is the beginning of the document.");
            // ExEnd:DocumentBuilderMoveToDocumentStartEnd            
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:13,代码来源:DocumentBuilderMovingCursor.cs

示例4: Convert

        /// <summary>
        /// Convert Excel workbook to Word document
        /// </summary>
        /// <param name="workbook">Input workbook</param>
        /// <returns>Word document</returns>
        internal Document Convert(Workbook workbook)
        {
            //Create new document
            Document doc = new Document();
            //Create an instance of the  DocumentBuilder class
            DocumentBuilder builder = new DocumentBuilder(doc);

            //Every worksheet in Excel workbook is represented as section in Word document
            foreach (Worksheet worksheet in workbook.Worksheets)
            {
                //Import PageSetup from Excel file to Word document
                //Orientation can be Portrait or Landscape
                builder.PageSetup.Orientation = ConvertPageOrientation(worksheet.PageSetup.Orientation);
                //Paper size can be A4, A3, Letter, etc.
                builder.PageSetup.PaperSize = ConvertPaperSize(worksheet.PageSetup.PaperSize);
                //Import margins
                builder.PageSetup.LeftMargin = ConvertUtil.InchToPoint(worksheet.PageSetup.LeftMarginInch); // 1cm = 28.35pt
                builder.PageSetup.RightMargin = ConvertUtil.InchToPoint(worksheet.PageSetup.RightMarginInch);
                builder.PageSetup.TopMargin = ConvertUtil.InchToPoint(worksheet.PageSetup.TopMarginInch);
                builder.PageSetup.BottomMargin = ConvertUtil.InchToPoint(worksheet.PageSetup.BottomMarginInch);

                //Get array of Word tables, every table in this array represents a part of Excel worksheet.
                ArrayList partsArray = GetTablePartsArray(worksheet, doc);
                //Insert all tables into the Word document
                foreach (Table table in partsArray)
                {
                    //Insert table
                    builder.CurrentSection.Body.AppendChild(table);
                    //Move coursore to document end
                    builder.MoveToDocumentEnd();
                    //Insert break if table is not last in the collection
                    if (!table.Equals(partsArray[partsArray.Count - 1]))
                    {
                        builder.InsertBreak(BreakType.SectionBreakNewPage);
                    }
                }
                //Insert break if current workseet is not last in the Excwl workbook
                if (!worksheet.Equals(workbook.Worksheets[workbook.Worksheets.Count - 1]) && partsArray.Count != 0)
                {
                    builder.InsertBreak(BreakType.SectionBreakNewPage);
                }
            }

            return doc;
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:50,代码来源:ConverterXls2Doc.cs

示例5: Main

        static void Main(string[] args)
        {
            Document doc = new Document("../../data/document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            //Shows how to access the current node in a document builder.
            Node curNode = builder.CurrentNode;
            Paragraph curParagraph = builder.CurrentParagraph;

            // Shows how to move a cursor position to a specified node.
            builder.MoveTo(doc.FirstSection.Body.LastParagraph);

            // Shows how to move a cursor position to the beginning or end of a document.
            builder.MoveToDocumentEnd();
            builder.Writeln("This is the end of the document.");

            builder.MoveToDocumentStart();
            builder.Writeln("This is the beginning of the document.");

            doc.Save("outputDocument.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:21,代码来源:Program.cs

示例6: Primer

        //ExStart
        //ExId:HeaderFooterPrimer
        //ExSummary:Maybe a bit complicated example, but demonstrates many things that can be done with headers/footers.
        public void Primer()
        {
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Aspose.Words.Section currentSection = builder.CurrentSection;
            Aspose.Words.PageSetup pageSetup = currentSection.PageSetup;

            // Specify if we want headers/footers of the first page to be different from other pages.
            // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
            // different headers/footers for odd and even pages.
            pageSetup.DifferentFirstPageHeaderFooter = true;

            // --- Create header for the first page. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // Set font properties for header text.
            builder.Font.Name = "Arial";
            builder.Font.Bold = true;
            builder.Font.Size = 14;
            // Specify header title for the first page.
            builder.Write("Aspose.Words Header/Footer Creation Primer - Title Page.");

            // --- Create header for pages other than first. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

            // Insert absolutely positioned image into the top/left corner of the header.
            // Distance from the top/left edges of the page is set to 10 points.
            string imageFileName = ExDir + "Aspose.Words.gif";
            builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 10, RelativeVerticalPosition.Page, 10, 50, 50, WrapType.Through);

            builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            // Specify another header title for other pages.
            builder.Write("Aspose.Words Header/Footer Creation Primer.");

            // --- Create footer for pages other than first. ---
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            // We use table with two cells to make one part of the text on the line (with page numbering)
            // to be aligned left, and the other part of the text (with copyright) to be aligned right.
            builder.StartTable();

            // Clear table borders.
            builder.CellFormat.ClearFormatting();

            builder.InsertCell();

            // Set first cell to 1/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 / 3);

            // Insert page numbering text here.
            // It uses PAGE and NUMPAGES fields to auto calculate current page number and total number of pages.
            builder.Write("Page ");
            builder.InsertField("PAGE", "");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES", "");

            // Align this text to the left.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;

            builder.InsertCell();
            // Set the second cell to 2/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 * 2 / 3);

            builder.Write("(C) 2001 Aspose Pty Ltd. All rights reserved.");

            // Align this text to the right.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;

            builder.EndRow();
            builder.EndTable();

            builder.MoveToDocumentEnd();
            // Make page break to create a second page on which the primary headers/footers will be seen.
            builder.InsertBreak(BreakType.PageBreak);

            // Make section break to create a third page with different page orientation.
            builder.InsertBreak(BreakType.SectionBreakNewPage);

            // Get the new section and its page setup.
            currentSection = builder.CurrentSection;
            pageSetup = currentSection.PageSetup;

            // Set page orientation of the new section to landscape.
            pageSetup.Orientation = Orientation.Landscape;

            // This section does not need different first page header/footer.
            // We need only one title page in the document and the header/footer for this page
            // has already been defined in the previous section
            pageSetup.DifferentFirstPageHeaderFooter = false;

            // This section displays headers/footers from the previous section by default.
            // Call currentSection.HeadersFooters.LinkToPrevious(false) to cancel this.
            // Page width is different for the new section and therefore we need to set
//.........这里部分代码省略.........
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:101,代码来源:ExHeaderFooter.cs

示例7: DocumentBuilderMoveToDocumentStartEnd

        public void DocumentBuilderMoveToDocumentStartEnd()
        {
            //ExStart
            //ExId:DocumentBuilderMoveToDocumentStartEnd
            //ExSummary:Shows how to move a cursor position to the beginning or end of a document.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToDocumentEnd();
            builder.Writeln("This is the end of the document.");

            builder.MoveToDocumentStart();
            builder.Writeln("This is the beginning of the document.");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:15,代码来源:ExDocumentBuilder.cs

示例8: 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

示例9: GenerateOutPutDocument

    protected void GenerateOutPutDocument(string outFileName)
    {
        //Open the template document
        Document doc = new Document(Server.MapPath("~/App_Data/DocumentBuilderDemo.docx"));

        //Once the builder is created, its cursor is positioned at the beginning of the document.
        DocumentBuilder builder = new DocumentBuilder(doc);

        builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
        BarCodeBuilder barCode = CreateBarCode();
        builder.InsertImage(barCode.BarCodeImage);

        builder.MoveToDocumentStart();

        System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("~/Web/Images/spring-air-logo-header.jpg"));
        builder.InsertImage(image);

        builder.InsertParagraph();
        builder.ParagraphFormat.ClearFormatting();
        builder.Font.ClearFormatting(); 

        builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
        builder.ParagraphFormat.Shading.ForegroundPatternColor = System.Drawing.Color.White;
        builder.ParagraphFormat.Shading.Texture = TextureIndex.TextureSolid;
        builder.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(0.3);
        builder.ParagraphFormat.SpaceBefore = 12;
        builder.ParagraphFormat.SpaceAfter = 12;
              
        builder.Font.Name = "Arial";
        builder.Font.Size = 9;
        builder.Write("ELECTRONIC TICKET - PASSENGER ITINERARY/RECEIPT");
        builder.InsertBreak(BreakType.LineBreak);
        builder.Writeln("CUSTOMER COPY - Powered by ASPOSE");
        builder.ParagraphFormat.ClearFormatting();

        builder.InsertHtml("<hr>");

        BuildBookingTable(builder);

        builder.MoveToDocumentEnd();
        builder.InsertBreak(BreakType.LineBreak);

        builder.InsertHtml("<hr>");

        builder.InsertParagraph();
        builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
        builder.InsertImage(barCode.BarCodeImage);


        doc.Save(Response, outFileName, ContentDisposition.Inline, null);
        Response.End();
    }
开发者ID:johnnydeamer,项目名称:Aspose_for_Spring.NET,代码行数:52,代码来源:ReservationConfirmationPage.aspx.cs


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