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


C# DocumentBuilder.Write方法代码示例

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


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

示例1: Main

        // Simple bar graph 
        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");
            }

			//createing new document
			Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Write text on the document 
            builder.Write("Simple Bar graph using Aspose.Words \t");

            //select the chart type (here chartType is bar) 
            Shape shape1 = builder.InsertChart(ChartType.Bar, 432, 252);

            // save the document in the given path
            doc.Save("SimpleBarGraph.doc");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:26,代码来源:Program.cs

示例2: Main

        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //ExStart
            //ExFor:DocumentBuilder.InsertField(string)
            //ExId:DocumentBuilderInsertNestedFields
            //ExSummary:Demonstrates how to insert fields nested within another field using DocumentBuilder.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a few page breaks (just for testing)
            for (int i = 0; i < 5; i++)
                builder.InsertBreak(BreakType.PageBreak);

            // Move the DocumentBuilder cursor into the primary footer.
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            // We want to insert a field like this:
            // { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" }
            Field field = builder.InsertField(@"IF ");
            builder.MoveTo(field.Separator);
            builder.InsertField("PAGE");
            builder.Write(" <> ");
            builder.InsertField("NUMPAGES");
            builder.Write(" \"See Next Page\" \"Last Page\" ");

            // Finally update the outer field to recalcaluate the final value. Doing this will automatically update
            // the inner fields at the same time.
            field.Update();

            doc.Save(dataDir + "InsertNestedFields Out.docx");
            //ExEnd
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:35,代码来源:Program.cs

示例3: 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();
			DocumentBuilder builder = new DocumentBuilder(doc);
			builder.Write("Image Before ReSize");
			//insert image from disk
			Shape shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg");
			// write text in document
			builder.Write("Image After ReSize ");
			//insert image from disk for resize
			shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg");
			// To change the shape size. ( ConvertUtil Provides helper functions to convert between various measurement units. like Converts inches to points.)
			shape.Width = ConvertUtil.InchToPoint(0.5);
			shape.Height = ConvertUtil.InchToPoint(0.5);
			// save new document
            builder.Document.Save("ImageReSize.doc");
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:27,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // We call this method to start building the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content.");

            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content.");
            // Call the following method to end the row and start a new row.
            builder.EndRow();

            // Build the first cell of the second row.
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            // Build the second cell.
            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content.");
            builder.EndRow();

            // Signal that we have finished building the table.
            builder.EndTable();

            // Save the document to disk.
            doc.Save("DocumentBuilder.CreateSimpleTable Out.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:32,代码来源:Program.cs

示例5: VerticalMerge

        // ExEnd:PrintCellMergeType
        public static void VerticalMerge( string dataDir)
        {
            // ExStart:VerticalMerge           
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.First;
            builder.Write("Text in merged cells.");

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.None;
            builder.Write("Text in one cell");
            builder.EndRow();

            builder.InsertCell();
            // This cell is vertically merged to the cell above and should be empty.
            builder.CellFormat.VerticalMerge = CellMerge.Previous;

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.None;
            builder.Write("Text in another cell");
            builder.EndRow();
            builder.EndTable();
            dataDir = dataDir + "Table.VerticalMerge_out.doc";

            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:VerticalMerge
            Console.WriteLine("\nTable created successfully with two columns with cells merged vertically in the first column.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:32,代码来源:MergedCells.cs

示例6: HorizontalMerge

        public void HorizontalMerge()
        {
            //ExStart
            //ExFor:CellMerge
            //ExFor:CellFormat.HorizontalMerge
            //ExId:HorizontalMerge
            //ExSummary:Creates a table with two rows with cells in the first row horizontally merged.
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCell();
            builder.CellFormat.HorizontalMerge = CellMerge.First;
            builder.Write("Text in merged cells.");

            builder.InsertCell();
            // This cell is merged to the previous and should be empty.
            builder.CellFormat.HorizontalMerge = CellMerge.Previous;
            builder.EndRow();

            builder.InsertCell();
            builder.CellFormat.HorizontalMerge = CellMerge.None;
            builder.Write("Text in one cell.");

            builder.InsertCell();
            builder.Write("Text in another cell.");
            builder.EndRow();
            builder.EndTable();
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:29,代码来源:ExCellFormat.cs

示例7: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithFields();

            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a few page breaks (just for testing)
            for (int i = 0; i < 5; i++)
                builder.InsertBreak(BreakType.PageBreak);

            // Move the DocumentBuilder cursor into the primary footer.
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            // We want to insert a field like this:
            // { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" }
            Field field = builder.InsertField(@"IF ");
            builder.MoveTo(field.Separator);
            builder.InsertField("PAGE");
            builder.Write(" <> ");
            builder.InsertField("NUMPAGES");
            builder.Write(" \"See Next Page\" \"Last Page\" ");

            // Finally update the outer field to recalcaluate the final value. Doing this will automatically update
            // the inner fields at the same time.
            field.Update();

            doc.Save(dataDir + "InsertNestedFields Out.docx");

            Console.WriteLine("\nInserted nested fields in the document successfully.\nFile saved at " + dataDir + "InsertNestedFields Out.docx");
        }
开发者ID:robv8r,项目名称:Aspose_Words_NET,代码行数:32,代码来源:InsertNestedFields.cs

示例8: VerticalMerge

        public void VerticalMerge()
        {
            //ExStart
            //ExFor:DocumentBuilder.InsertCell
            //ExFor:DocumentBuilder.EndRow
            //ExFor:CellMerge
            //ExFor:CellFormat.VerticalMerge
            //ExId:VerticalMerge
            //ExSummary:Creates a table with two columns with cells merged vertically in the first column.
            Aspose.Words.Document doc = new Aspose.Words.Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.First;
            builder.Write("Text in merged cells.");

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.None;
            builder.Write("Text in one cell");
            builder.EndRow();

            builder.InsertCell();
            // This cell is vertically merged to the cell above and should be empty.
            builder.CellFormat.VerticalMerge = CellMerge.Previous;

            builder.InsertCell();
            builder.CellFormat.VerticalMerge = CellMerge.None;
            builder.Write("Text in another cell");
            builder.EndRow();
            builder.EndTable();
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:32,代码来源:ExCellFormat.cs

示例9: SimpleTable

        private static void SimpleTable(string dataDir)
        {
            // ExStart:SimpleTable
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            // We call this method to start building the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content.");
            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content.");
            // Call the following method to end the row and start a new row.
            builder.EndRow();

            // Build the first cell of the second row.
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            // Build the second cell.
            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content.");
            builder.EndRow();

            // Signal that we have finished building the table.
            builder.EndTable();

            dataDir = dataDir + "DocumentBuilder.CreateSimpleTable_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:SimpleTable
            Console.WriteLine("\nSimple table created successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:33,代码来源:InsertTableUsingDocumentBuilder.cs

示例10: Main

        static void Main(string[] args)
        {
            // Create an empty document and DocumentBuilder object.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Create a Comment.
            Comment comment = new Comment(doc);
            // Insert some text into the comment.
            Paragraph commentParagraph = new Paragraph(doc);
            commentParagraph.AppendChild(new Run(doc, "This is comment!!!"));
            comment.AppendChild(commentParagraph);

            // Create CommentRangeStart and CommentRangeEnd.
            int commentId = 0;
            CommentRangeStart start = new CommentRangeStart(doc, commentId);
            CommentRangeEnd end = new CommentRangeEnd(doc, commentId);

            // Insert some text into the document.
            builder.Write("This is text before comment ");
            // Insert comment and comment range start.
            builder.InsertNode(comment);
            builder.InsertNode(start);
            // Insert some more text.
            builder.Write("This is commented text ");
            // Insert end of comment range.
            builder.InsertNode(end);
            // And finaly insert some more text.
            builder.Write("This is text aftr comment");

            // Save output document.
            doc.Save("Insert a Comment in Word Processing document.docx");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:33,代码来源:Program.cs

示例11: 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();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Please make sure to visit ");

            // Specify font formatting for the hyperlink.
            builder.Font.Color = Color.Blue;
            builder.Font.Underline = Underline.Single;
            // Insert the link.
            builder.InsertHyperlink("Aspose Website", "http://www.aspose.com", false);

            // Revert to default formatting.
            builder.Font.ClearFormatting();

            builder.Write(" for more information.");
            doc.Save("Insert_Hyperlink_In_Document.doc");

        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:31,代码来源:Program.cs

示例12: CreateDocumentFillWithDummyText

        /// <summary>
        /// Create new document with text
        /// </summary>
        internal static Document CreateDocumentFillWithDummyText()
        {
            Document doc = new Document();

            //Remove the previous changes of the document
            doc.RemoveAllChildren();

            //Set the document author
            doc.BuiltInDocumentProperties.Author = "Test Author";

            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Page ");
            builder.InsertField("PAGE", "");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES", "");

            //Insert new table with two rows and two cells
            InsertTable(builder);

            builder.Writeln("Hello World!");

            // Continued on page 2 of the document content
            builder.InsertBreak(BreakType.PageBreak);

            //Insert TOC entries
            InsertToc(builder);

            return doc;
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:33,代码来源:DocumentHelper.cs

示例13: Run

        public static void Run()
        {
            // ExStart:DocumentBuilderBuildTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();
            // Initialize document.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();

            // Insert a cell
            builder.InsertCell();
            // Use fixed column widths.
            table.AutoFit(AutoFitBehavior.FixedColumnWidths);

            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
            builder.Write("This is row 1 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.Write("This is row 1 cell 2");

            builder.EndRow();

            // Insert a cell
            builder.InsertCell();

            // Apply new row formatting
            builder.RowFormat.Height = 100;
            builder.RowFormat.HeightRule = HeightRule.Exactly;

            builder.CellFormat.Orientation = TextOrientation.Upward;
            builder.Writeln("This is row 2 cell 1");

            // Insert a cell
            builder.InsertCell();
            builder.CellFormat.Orientation = TextOrientation.Downward;
            builder.Writeln("This is row 2 cell 2");

            builder.EndRow();

            builder.EndTable();
            dataDir = dataDir + "DocumentBuilderBuildTable_out.doc";
            doc.Save(dataDir);
            // ExEnd:DocumentBuilderBuildTable
            Console.WriteLine("\nTable build successfully using DocumentBuilder.\nFile saved at " + dataDir);
        }     
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:48,代码来源:DocumentBuilderBuildTable.cs

示例14: Run

        public static void Run()
        {
            // ExStart:ChangeFieldUpdateCultureSource
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithFields();
            // We will test this functionality creating a document with two fields with date formatting
            // ExStart:DocumentBuilderInsertField
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert content with German locale.
            builder.Font.LocaleId = 1031;
            builder.InsertField("MERGEFIELD Date1 \\@ \"dddd, d MMMM yyyy\"");
            builder.Write(" - ");
            builder.InsertField("MERGEFIELD Date2 \\@ \"dddd, d MMMM yyyy\"");
            // ExEnd:DocumentBuilderInsertField
            // Shows how to specify where the culture used for date formatting during field update and mail merge is chosen from.
            // Set the culture used during field update to the culture used by the field.            
            doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
            doc.MailMerge.Execute(new string[] { "Date2" }, new object[] { new DateTime(2011, 1, 01) });
            dataDir = dataDir + "Field.ChangeFieldUpdateCultureSource_out.doc";
            doc.Save(dataDir);
            // ExEnd:ChangeFieldUpdateCultureSource

            Console.WriteLine("\nCulture changed successfully used in formatting fields during update.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:26,代码来源:ChangeFieldUpdateCultureSource.cs

示例15: 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();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Start building a the table.
            builder.StartTable();
            builder.InsertCell();
            builder.Write("Row 1, Cell 1 Content");

            // Build the second cell
            builder.InsertCell();
            builder.Write("Row 1, Cell 2 Content");

            // End previous row and start new
            builder.EndRow();

            // Build the first cell of 2nd row
            builder.InsertCell();
            builder.Write("Row 2, Cell 1 Content");

            builder.InsertCell();
            builder.Write("Row 2, Cell 2 Content");

            builder.EndRow();

            // End the table
            builder.EndTable();

            Range range = doc.Sections[0].Range;
            range.Delete();

            String text = doc.Range.Text;

            System.Console.WriteLine(text);
            System.Console.ReadKey();
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:47,代码来源:Program.cs


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