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


C# Paragraph.AppendChild方法代码示例

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


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

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

示例2: Main

        static void Main(string[] args)
        {
            Console.Write("Username: ");
            String user = Console.ReadLine();

            WordprocessingDocument package = WordprocessingDocument.Create(@"C:\Users\" + user + @"\Desktop\test.docx", WordprocessingDocumentType.Document);
            MainDocumentPart main = package.AddMainDocumentPart();
            main.Document = new Document();
            Document document1 = main.Document;
            Body body = document1.AppendChild(new Body());
            document1 = package.MainDocumentPart.Document;
            document1.Save();

            OpenXmlHelper document = new OpenXmlHelper(package, main);
            //You will have to have all the files below if you want to successfully test this.
            //Image Formats
            Paragraph para = new Paragraph();
            Run run = new Run();
            run.AppendChild(new Text("These are Image Formats"));
            para.AppendChild(run);
            document.AddParagraph(para);
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.jpg");
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.gif");
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.png");
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.tif");
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.bmp");
            document.AddImage(@"C:\Users\" + user + @"\Desktop\test\test.ico");
            //Office XML Formats
            para = new Paragraph();
            run = new Run();
            run.AppendChild(new Text("These are Office XML Formats"));
            para.AppendChild(run);
            document.AddParagraph(para);
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.docx","test.docx");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.xlsx", "test.xlsx");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.pptx", "test.pptx");
            //Office Basic Formats
            para = new Paragraph();
            run = new Run();
            run.AppendChild(new Text("These are Office Basic Formats"));
            para.AppendChild(run);
            document.AddParagraph(para);
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.doc", "test.doc");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.xls", "test.xls");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.vsd", "test.vsd");
            //Object Formats
            para = new Paragraph();
            run = new Run();
            run.AppendChild(new Text("These are Object Formats"));
            para.AppendChild(run);
            document.AddParagraph(para);
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.xml", "test.xml");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.txt", "test.txt");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.pdf", "test.pdf");
            document.AddObject(@"C:\Users\" + user + @"\Desktop\test\test.zip", "test.zip");

            document.Close();
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
开发者ID:vandersmissenc,项目名称:OpenXmlDocumentGenerator,代码行数:60,代码来源:Program.cs

示例3: ProcessNonLinkText

        private void ProcessNonLinkText(DocxNode node, ref Paragraph paragraph)
        {
            foreach (DocxNode child in node.Children)
            {
                if (child.IsText)
                {
                    if (paragraph == null)
                    {
                        paragraph = node.Parent.AppendChild(new Paragraph());
                        OnParagraphCreated(node.ParagraphNode, paragraph);
                    }

                    if (!IsEmptyText(child.InnerHtml))
                    {
                        Run run = paragraph.AppendChild<Run>(new Run(new Text()
                         {
                             Text = ClearHtml(child.InnerHtml),
                             Space = SpaceProcessingModeValues.Preserve
                         }));

                        RunCreated(node, run);
                    }
                }
                else
                {
                    child.ParagraphNode = node.ParagraphNode;
                    child.Parent = node.Parent;
                    node.CopyExtentedStyles(child);
                    ProcessChild(child, ref paragraph);
                }
            }
        }
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:32,代码来源:DocxA.cs

示例4: ProcessBody

        private void ProcessBody(DocxNode node, ref Paragraph paragraph)
        {
            while (node != null)
            {
                if (node.IsText)
                {
                    if (!IsEmptyText(node.InnerHtml))
                    {
                        if (paragraph == null)
                        {
                            paragraph = body.AppendChild(new Paragraph());
                            OnParagraphCreated(node, paragraph);
                        }

                        Run run = paragraph.AppendChild(new Run(new Text()
                        {
                            Text = ClearHtml(node.InnerHtml),
                            Space = SpaceProcessingModeValues.Preserve
                        }));

                        RunCreated(node, run);
                    }
                }
                else
                {
                    node.ParagraphNode = node;
                    node.Parent = body;
                    ProcessChild(node, ref paragraph);
                }

                node = node.Next;
            }
        }
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:33,代码来源:DocxBody.cs

示例5: 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");

            string watermarkText = "Aspose.Words for .NET";

            // Create a watermark shape. This will be a WordArt shape.
            // You are free to try other shape types as watermarks.
            Shape watermark = new Shape(doc, ShapeType.TextPlainText);

            // Set up the text of the watermark.
            watermark.TextPath.Text = watermarkText;
            watermark.TextPath.FontFamily = "Arial";
            watermark.Width = 500;
            watermark.Height = 100;

            // Text will be directed from the bottom-left to the top-right corner.
            watermark.Rotation = -40;

            // Remove the following two lines if you need a solid black text.
            watermark.Fill.Color = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark
            watermark.StrokeColor = System.Drawing.Color.Gray; // Try LightGray to get more Word-style watermark

            // Place the watermark in the page center.
            watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
            watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
            watermark.WrapType = WrapType.None;
            watermark.VerticalAlignment = VerticalAlignment.Center;
            watermark.HorizontalAlignment = HorizontalAlignment.Center;

            // Create a new paragraph and append the watermark to this paragraph.
            Paragraph watermarkPara = new Paragraph(doc);
            watermarkPara.AppendChild(watermark);

            // Insert the watermark into all headers of each document section.
            foreach (Section sect in doc.Sections)
            {
                // There could be up to three different headers in each section, since we want
                // the watermark to appear on all pages, insert into all headers.
                insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
                insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
                insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);
            }

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

示例6: SetCommentText

        /// <summary>
        /// Sets a comments text.
        /// </summary>
        /// <param name="comment">The commit to modify.</param>
        /// <param name="text">The new comment text.</param>
        private static void SetCommentText(Comment comment, string text)
        {
            if (comment.ChildNodes.Count > 0)
                comment.ChildNodes.Clear();

            // Insert some text into the comment.
            var commentParagraph = new Paragraph(comment.Document);
            commentParagraph.AppendChild(new Run(comment.Document, text));
            comment.AppendChild(commentParagraph);
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:15,代码来源:CommentBuilder.cs

示例7: Process

        internal override void Process(DocxNode node, ref Paragraph paragraph)
        {
            if (node.IsNull() || node.Parent == null || IsHidden(node))
            {
                return;
            }

            foreach (DocxNode child in node.Children)
            {
                if (child.IsText)
                {
                    if (!IsEmptyText(child.InnerHtml))
                    {
                        ApplyOpenQuoteIfEmpty(node, ref paragraph);

                        Run run = paragraph.AppendChild(new Run(new Text()
                        {
                            Text = ClearHtml(child.InnerHtml),
                            Space = SpaceProcessingModeValues.Preserve
                        }));

                        RunCreated(node, run);
                    }
                }
                else
                {
                    child.ParagraphNode = node.ParagraphNode;
                    child.Parent = node.Parent;
                    node.CopyExtentedStyles(child);
                    ApplyOpenQuoteIfEmpty(node, ref paragraph);
                    ProcessChild(child, ref paragraph);
                }
            }

            if (paragraph != null && hasOpenQuote)
            {
                paragraph.AppendChild(new Run(new Text() { Text = "\"" }));
            }
        }
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:39,代码来源:DocxQ.cs

示例8: Run

        public static void Run()
        {
            // ExStart:AnchorComment
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithComments();
            Document doc = new Document();

            Paragraph para1 = new Paragraph(doc);
            Run run1 = new Run(doc, "Some ");
            Run run2 = new Run(doc, "text ");
            para1.AppendChild(run1);
            para1.AppendChild(run2);
            doc.FirstSection.Body.AppendChild(para1);

            Paragraph para2 = new Paragraph(doc);
            Run run3 = new Run(doc, "is ");
            Run run4 = new Run(doc, "added ");
            para2.AppendChild(run3);
            para2.AppendChild(run4);
            doc.FirstSection.Body.AppendChild(para2);

            Comment comment = new Comment(doc, "Awais Hafeez", "AH", DateTime.Today);
            comment.Paragraphs.Add(new Paragraph(doc));
            comment.FirstParagraph.Runs.Add(new Run(doc, "Comment text."));

            CommentRangeStart commentRangeStart = new CommentRangeStart(doc, comment.Id);
            CommentRangeEnd commentRangeEnd = new CommentRangeEnd(doc, comment.Id);

            run1.ParentNode.InsertAfter(commentRangeStart, run1);
            run3.ParentNode.InsertAfter(commentRangeEnd, run3);
            commentRangeEnd.ParentNode.InsertAfter(comment, commentRangeEnd);
           
            dataDir = dataDir + "Anchor.Comment_out.doc";
            // Save the document.
            doc.Save(dataDir);
            // ExEnd:AnchorComment
            Console.WriteLine("\nComment anchored successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:38,代码来源:AnchorComment.cs

示例9: Process

        internal override void Process(DocxNode node, ref Paragraph paragraph)
		{
            if (!node.IsNull() && node.Parent != null || IsHidden(node))
			{
				if (paragraph == null)
				{
                    paragraph = node.Parent.AppendChild(new Paragraph());
                    OnParagraphCreated(node.ParagraphNode, paragraph);
				}
				
				Run run = paragraph.AppendChild(new Run(new Break()));
                RunCreated(node, run);
			}
		}
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:14,代码来源:DocxBr.cs

示例10: ApplyOpenQuoteIfEmpty

        private void ApplyOpenQuoteIfEmpty(DocxNode node, ref Paragraph paragraph)
        {
            if (paragraph == null)
            {
                paragraph = CreateParagraph(node);
            }

            if (hasOpenQuote)
            {
                return;
            }

            paragraph.AppendChild(new Run(new Text() { Text = "\"" }));
            hasOpenQuote = true;
        }
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:15,代码来源:DocxQ.cs

示例11: CreateTemplateDocumentForReportingEngine

        /// <summary>
        /// Create new document with textbox shape and some query
        /// </summary>
        internal static Document CreateTemplateDocumentForReportingEngine(string templateText)
        {
            Document doc = new Document();

            //ToDo: Maybe in future add shape(object) as parameter
            // Create textbox shape.
            Shape textbox = new Shape(doc, ShapeType.TextBox);
            textbox.Width = 431.5;
            textbox.Height = 346.35;

            Paragraph paragraph = new Paragraph(doc);
            paragraph.AppendChild(new Run(doc, templateText));

            // Insert paragraph into the textbox.
            textbox.AppendChild(paragraph);

            // Insert textbox into the document.
            doc.FirstSection.Body.FirstParagraph.AppendChild(textbox);

            return doc;
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:24,代码来源:DocumentHelper.cs

示例12: InsertWatermarkText

        /// <summary>
        /// Inserts a watermark into a document.
        /// </summary>
        /// <param name="doc">The input document.</param>
        /// <param name="watermarkText">Text of the watermark.</param>
        private static void InsertWatermarkText(Document doc, string watermarkText)
        {
            // Create a watermark shape. This will be a WordArt shape. 
            // You are free to try other shape types as watermarks.
            Shape watermark = new Shape(doc, ShapeType.TextPlainText);

            // Set up the text of the watermark.
            watermark.TextPath.Text = watermarkText;
            watermark.TextPath.FontFamily = "Arial";
            watermark.Width = 500;
            watermark.Height = 100;
            // Text will be directed from the bottom-left to the top-right corner.
            watermark.Rotation = -40;
            // Remove the following two lines if you need a solid black text.
            watermark.Fill.Color = Color.Gray; // Try LightGray to get more Word-style watermark
            watermark.StrokeColor = Color.Gray; // Try LightGray to get more Word-style watermark

            // Place the watermark in the page center.
            watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
            watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
            watermark.WrapType = WrapType.None;
            watermark.VerticalAlignment = VerticalAlignment.Center;
            watermark.HorizontalAlignment = HorizontalAlignment.Center;

            // Create a new paragraph and append the watermark to this paragraph.
            Paragraph watermarkPara = new Paragraph(doc);
            watermarkPara.AppendChild(watermark);

            // Insert the watermark into all headers of each document section.
            foreach (Section sect in doc.Sections)
            {
                // There could be up to three different headers in each section, since we want
                // The watermark to appear on all pages, insert into all headers.
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
                InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);
            }
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:43,代码来源:AddWatermark.cs

示例13: CreateParagraph

        /// <summary>
        /// Creates the paragraph.
        /// </summary>
        /// <param name="openXmlCompositeElement">The open XML composite element.</param>
        /// <param name="runs">The runs.</param>
        /// <returns>Returns the paragraph element</returns>
        private static Paragraph CreateParagraph(OpenXmlCompositeElement openXmlCompositeElement, List<Run> runs)
        {
            var paragraphProperties = openXmlCompositeElement.Descendants<ParagraphProperties>().FirstOrDefault();
            Paragraph para;

            if (paragraphProperties != null)
            {
                para = new Paragraph(paragraphProperties.CloneNode(true));
                foreach (var run in runs)
                {
                    para.AppendChild(run);
                }
            }
            else
            {
                para = new Paragraph();
                foreach (var run in runs)
                {
                    para.AppendChild(run);
                }
            }

            return para;
        }
开发者ID:NikolayKash,项目名称:BuildManager,代码行数:30,代码来源:OpenXmlHelper.cs

示例14: AddRunsToSdtContentCell

        /// <summary>
        /// Adds the runs to SDT content cell.
        /// </summary>
        /// <param name="sdtContentCell">The SDT content cell.</param>
        /// <param name="runs">The runs.</param>
        private static void AddRunsToSdtContentCell(OpenXmlCompositeElement sdtContentCell, IEnumerable<Run> runs)
        {
            var cell = new TableCell();
            var para = new Paragraph();
            para.RemoveAllChildren();

            foreach (var run in runs)
            {
                para.AppendChild(run);
            }

            cell.AppendChild(para);
            SetSdtContentKeepingPermissionElements(sdtContentCell, cell);
        }
开发者ID:NikolayKash,项目名称:BuildManager,代码行数:19,代码来源:OpenXmlHelper.cs

示例15: BuildCell

        private TableCell BuildCell(string text, int gridSpan = 1, VerticalMerge vm = null, bool bold = false)
        {
            TableCell cell = new TableCell();
            Paragraph p = new Paragraph();
            ParagraphProperties paragraphProperties = new ParagraphProperties();

            Justification justification = new Justification() { Val = JustificationValues.Center };
            paragraphProperties.Append(justification);

            if (bold)
            {
                ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();
                Bold boldStyle = new Bold();

                paragraphMarkRunProperties.Append(boldStyle);
                paragraphProperties.Append(paragraphMarkRunProperties);
            }
            p.Append(paragraphProperties);

            if (!string.IsNullOrEmpty(text))
            {
                Run r = new Run();
                RunProperties runProperties = new RunProperties();

                if (bold)
                {
                    Bold boldStyle = new Bold();

                    runProperties.Append(boldStyle);
                }

                r.Append(runProperties);

                Text t = new Text { Text = text };
                r.AppendChild<Text>(t);

                p.AppendChild<Run>(r);
            }

            TableCellProperties cellProperty = new TableCellProperties();
            TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };

            cellProperty.Append(tableCellVerticalAlignment1);

            if (gridSpan > 1)
            {
                GridSpan gs = new GridSpan { Val = gridSpan };
                cellProperty.Append(gs);
            }

            if (vm != null)
            {
                cellProperty.Append(vm);
            }

            cell.Append(cellProperty);
            cell.Append(p);

            return cell;
        }
开发者ID:dalinhuang,项目名称:cy-pdcpms,代码行数:60,代码来源:OutgoingNoticeController.cs


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