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


C# Paragraph.Remove方法代码示例

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


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

示例1: VisitParagraphStart

            /// <summary>
            /// Called when a Paragraph node is encountered in the document.
            /// </summary>
            public override VisitorAction VisitParagraphStart(Paragraph paragraph)
            {
                if (isHidden(paragraph))
                    paragraph.Remove();

                return VisitorAction.Continue;
            }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:10,代码来源:ExFont.cs

示例2: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            var surah = int.Parse(context.Request["surah"] ?? "1");
            var fileName = "Quran_Surah_" + surah + ".docx";
            //context.Response.AppendHeader("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            context.Response.AppendHeader("Content-Type", "application/msword");
            context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            //context.Response.ContentEncoding = Encoding.UTF8;

            // Open a Wordprocessing document for editing.
            var path = context.Server.MapPath("~/App_Data/" + fileName);
            if (File.Exists(path))
                File.Delete(path);

            File.Copy(context.Server.MapPath("~/App_Data/Template.docx"), path);
            using (WordprocessingDocument package = WordprocessingDocument.Open(path, true))
            {
                MainDocumentPart main = package.MainDocumentPart;
                StyleDefinitionsPart stylePart = main.StyleDefinitionsPart;
                FootnotesPart fpart = main.FootnotesPart;
                Body body = main.Document.Body;

                //MainDocumentPart main = package.AddMainDocumentPart();
                //StyleDefinitionsPart stylePart = AddStylesPartToPackage(package);
                //CreateDefaultStyles(stylePart);
                //FootnotesPart fpart = main.AddNewPart<FootnotesPart>();

                //main.Document = new Document();
                //Body body = main.Document.AppendChild<Body>(new Body());
                //body.AppendChild(
                //    new SectionProperties(
                //        new FootnoteProperties(
                //            new NumberingFormat() { Val = NumberFormatValues.LowerLetter },
                //            new NumberingRestart() { Val = RestartNumberValues.EachPage })));

                using (var quran = new QuranObjects.QuranContext())
                {
                    var translations = from mt in quran.MyTranslations where mt.SurahNo == surah select mt;
                    var lastVersePara = new Paragraph();

                    foreach (var translation in translations)
                    {
                        // Emit headings as Heading 2
                        if (translation.Heading.Length > 0)
                        {
                            var headingPara = body.AppendChild<Paragraph>(
                                new Paragraph(new Run2(new Text2(translation.Heading))));
                            ApplyStyleToParagraph(stylePart, GetStyleIdFromStyleName(stylePart, "My Heading 2"), headingPara);

                            if (lastVersePara.ChildElements.OfType<Run>().Count() == 0)
                                lastVersePara.Remove();

                            lastVersePara = body.AppendChild<Paragraph>(new Paragraph());
                            ApplyStyleToParagraph(stylePart, GetStyleIdFromStyleName(stylePart, "Verse"), lastVersePara);
                        }

                        // Find all footnotes from the footnote translation
                        var footnotes = new List<string>();
                        var matches = new Regex(@"(\*+)([^\*]*)").Matches(translation.Footnote);
                        foreach (Match match in matches)
                        {
                            var footnoteText = match.Groups[2].Value;
                            footnotes.Add(footnoteText);
                        }

                        // Generate the verse number
                        var translationAyahNoEnglish = translation.AyahNo.ToString();
                        var banglaVerseNo = new String(Array.ConvertAll(translationAyahNoEnglish.ToCharArray(), (c) => (char)('০' + (char)(c - '0'))));

                        AddSuperscriptText(lastVersePara, banglaVerseNo);
                        AddText(lastVersePara, " ", stylePart);

                        // Emit the translation while generating the footnote references
                        var translationFootnotes = new Regex(@"([^\*]*)(\*+)([^\*]*)").Matches(translation.Translation);
                        if (translationFootnotes.Count == 0)
                        {
                            AddText(lastVersePara, translation.Translation, stylePart);

                            // If there was no footnote marker in the translation text, then
                            // add the entire footnote at the end of the translation
                            if (translation.Footnote.Trim().Length > 0)
                            {
                                var footnoteId = AddFootnoteReference(fpart, stylePart, translation.Footnote.Replace("*", ""));
                                AddFootnote(lastVersePara, footnoteId, stylePart);
                            }
                        }

                        foreach (Match match in translationFootnotes)
                        {
                            var beforeText = match.Groups[1].Value;
                            var footnoteMarker = match.Groups[2].Value;
                            var afterText = match.Groups[3].Value;

                            AddText(lastVersePara, beforeText, stylePart);

                            // Create a footnote first and then add a footnote reference
                            var footnoteId = AddFootnoteReference(fpart, stylePart, footnotes[footnoteMarker.Length-1]);
                            AddFootnote(lastVersePara, footnoteId, stylePart);
                            AddText(lastVersePara, afterText, stylePart);
                        }
//.........这里部分代码省略.........
开发者ID:cometofsky,项目名称:Quran,代码行数:101,代码来源:GenerateWord.ashx.cs

示例3: VisitParagraphEnd

            public override VisitorAction VisitParagraphEnd(Paragraph paragraph)
            {
                if (mFieldDepth > 0)
                {
                    // The field code that is being converted continues onto another paragraph. We
                    // need to copy the remaining content from this paragraph onto the next paragraph.
                    Node nextParagraph = paragraph.NextSibling;

                    // Skip ahead to the next available paragraph.
                    while (nextParagraph != null && nextParagraph.NodeType != NodeType.Paragraph)
                        nextParagraph = nextParagraph.NextSibling;

                    // Copy all of the nodes over. Keep a list of these nodes so we know not to remove them.
                    while (paragraph.HasChildNodes)
                    {
                        mNodesToSkip.Add(paragraph.LastChild);
                        ((Paragraph)nextParagraph).PrependChild(paragraph.LastChild);
                    }

                    paragraph.Remove();
                }

                return VisitorAction.Continue;
            }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:24,代码来源:Program.cs

示例4: VisitParagraphStart

        public override VisitorAction VisitParagraphStart(Paragraph paragraph)
        {
            if (paragraph.IsListItem)
            {
                List paraList = paragraph.ListFormat.List;
                ListLevel currentLevel = paragraph.ListFormat.ListLevel;

                // Since we have encountered a list item we need to check if this will reset
                // any subsequent list levels and if so then update the numbering of the level.
                int currentListLevelNumber = paragraph.ListFormat.ListLevelNumber;
                for (int i = currentListLevelNumber + 1; i < paraList.ListLevels.Count; i++)
                {
                    ListLevel paraLevel = paraList.ListLevels[i];

                    if (paraLevel.RestartAfterLevel >= currentListLevelNumber)
                    {
                        // This list level needs to be reset after the current list number.
                        mListLevelToListNumberLookup[paraLevel] = paraLevel.StartAt;
                    }
                }

                // A list which was used on a previous page is present on a different page, the list
                // needs to be copied so list numbering is retained when extracting individual pages.
                if (ContainsListLevelAndPageChanged(paragraph))
                {
                    List copyList = paragraph.Document.Lists.AddCopy(paraList);
                    mListLevelToListNumberLookup[currentLevel] = paragraph.ListLabel.LabelValue;

                    // Set the numbering of each list level to start at the numbering of the level on the previous page.
                    for (int i = 0; i < paraList.ListLevels.Count; i++)
                    {
                        ListLevel paraLevel = paraList.ListLevels[i];

                        if (mListLevelToListNumberLookup.ContainsKey(paraLevel))
                            copyList.ListLevels[i].StartAt = (int)mListLevelToListNumberLookup[paraLevel];
                    }

                    mListToReplacementListLookup[paraList] = copyList;
                }

                if (mListToReplacementListLookup.ContainsKey(paraList))
                {
                    // This paragraph belongs to a list from a previous page. Apply the replacement list.
                    paragraph.ListFormat.List = (List)mListToReplacementListLookup[paraList];
                    // This is a trick to get the spacing of the list level to set correctly.
                    paragraph.ListFormat.ListLevelNumber += 0;
                }

                mListLevelToPageLookup[currentLevel] = mPageNumberFinder.GetPage(paragraph);
                mListLevelToListNumberLookup[currentLevel] = paragraph.ListLabel.LabelValue;
            }

            Section prevSection = (Section)paragraph.ParentSection.PreviousSibling;
            Paragraph prevBodyPara = paragraph.PreviousSibling as Paragraph;

            Paragraph prevSectionPara = prevSection != null && paragraph == paragraph.ParentSection.Body.FirstChild ? prevSection.Body.LastParagraph : null;
            Paragraph prevParagraph = prevBodyPara != null ? prevBodyPara : prevSectionPara;

            if (paragraph.IsEndOfSection && !paragraph.HasChildNodes)
                paragraph.Remove();

            // Paragraphs across pages can merge or remove spacing depending upon the previous paragraph.
            if (prevParagraph != null)
            {
                if (mPageNumberFinder.GetPage(paragraph) != mPageNumberFinder.GetPageEnd(prevParagraph))
                {
                    if (paragraph.IsListItem && prevParagraph.IsListItem && !prevParagraph.IsEndOfSection)
                        prevParagraph.ParagraphFormat.SpaceAfter = 0;
                    else if (prevParagraph.ParagraphFormat.StyleName == paragraph.ParagraphFormat.StyleName && paragraph.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle)
                        paragraph.ParagraphFormat.SpaceBefore = 0;
                    else if (paragraph.ParagraphFormat.PageBreakBefore || (prevParagraph.IsEndOfSection && prevSection.PageSetup.SectionStart != SectionStart.NewColumn))
                        paragraph.ParagraphFormat.SpaceBefore = System.Math.Max(paragraph.ParagraphFormat.SpaceBefore - prevParagraph.ParagraphFormat.SpaceAfter, 0);
                    else
                        paragraph.ParagraphFormat.SpaceBefore = 0;
                }
            }

            return VisitorAction.Continue;
        }
开发者ID:animaal,项目名称:Aspose_Words_NET,代码行数:79,代码来源:PageSplitter.cs


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