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


C# Document.RemoveAllChildren方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            // The document that the other documents will be appended to.
            Document dstDoc = new Document();

            // We should call this method to clear this document of any existing content.
            dstDoc.RemoveAllChildren();

            int recordCount = 1;
            for (int i = 1; i <= recordCount; i++)
            {
                // Open the document to join.
                Document srcDoc = new Document("src.doc");

                // Append the source document at the end of the destination document.
                dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
                Document doc2 = new Document("Section.ModifyPageSetupInAllSections.doc");
                dstDoc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
                // In automation you were required to insert a new section break at this point, however in Aspose.Words we
                // don't need to do anything here as the appended document is imported as separate sectons already.

                // If this is the second document or above being appended then unlink all headers footers in this section
                // from the headers and footers of the previous section.
                if (i > 1)
                    dstDoc.Sections[i].HeadersFooters.LinkToPrevious(false);
            }
            dstDoc.Save("updated.doc");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:28,代码来源:Program.cs

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

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

            builder.Writeln("Hello World!");

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

            //Insert TOC entries
            InsertToc(doc);

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

示例3: Main

        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string SrcFileName = FilePath + "Joining Mutiple documents 1.docx";
            string DestFileName = FilePath + "Joining Mutiple documents 2.docx";
            
            // The document that the other documents will be appended to.
            Document dstDoc = new Document();

            // We should call this method to clear this document of any existing content.
            dstDoc.RemoveAllChildren();

            int recordCount = 1;
            for (int i = 1; i <= recordCount; i++)
            {
                // Open the document to join.
                Document srcDoc = new Document(SrcFileName);

                // Append the source document at the end of the destination document.
                dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
                Document doc2 = new Document(DestFileName);
                dstDoc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
                // If this is the second document or above being appended then unlink all headers footers in this section
                // from the headers and footers of the previous section.
                if (i > 1)
                    dstDoc.Sections[i].HeadersFooters.LinkToPrevious(false);
            }
            dstDoc.Save(DestFileName);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:29,代码来源:Program.cs

示例4: CreateDocumentWithoutDummyText

        /// <summary>
        /// Create new document without run in the paragraph
        /// </summary>
        internal static Document CreateDocumentWithoutDummyText()
        {
            Document doc = new Document();

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

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

            //Create paragraph without run
            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Writeln();

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

示例5: AppendDocument_BaseDocument

        public static void AppendDocument_BaseDocument()
        {
            //ExStart
            //ExId:AppendDocument_BaseDocument
            //ExSummary:Shows how to remove all content from a document before using it as a base to append documents to.
            // Use a blank document as the destination document.
            Document dstDoc = new Document();
            Document srcDoc = new Document(gDataDir + "TestFile.Source.doc");

            // The destination document is not actually empty which often causes a blank page to appear before the appended document
            // This is due to the base document having an empty section and the new document being started on the next page.
            // Remove all content from the destination document before appending.
            dstDoc.RemoveAllChildren();

            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
            dstDoc.Save(gDataDir + "TestFile.BaseDocument Out.doc");
            //ExEnd
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:18,代码来源:Program.cs

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

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

            //Insert new paragraph with text
            builder.Writeln("Hello World!");

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

示例7: Run

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

            //ExStart
            //ExId:AppendDocument_BaseDocument
            //ExSummary:Shows how to remove all content from a document before using it as a base to append documents to.
            // Use a blank document as the destination document.
            Document dstDoc = new Document();
            Document srcDoc = new Document(dataDir + "TestFile.Source.doc");

            // The destination document is not actually empty which often causes a blank page to appear before the appended document
            // This is due to the base document having an empty section and the new document being started on the next page.
            // Remove all content from the destination document before appending.
            dstDoc.RemoveAllChildren();

            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
            dstDoc.Save(dataDir + "TestFile.BaseDocument Out.doc");

            Console.WriteLine("\nDocument appended successfully with all content removed from the destination document.\nFile saved at " + dataDir + "TestFile.BaseDocument Out.doc");
        }
开发者ID:robv8r,项目名称:Aspose_Words_NET,代码行数:22,代码来源:BaseDocument.cs

示例8: SaveHtmlTopic

        /// <summary>
        /// Saves one section of a document as an HTML file.
        /// Any embedded images are saved as separate files in the same folder as the HTML file.
        /// </summary>
        private static void SaveHtmlTopic(Section section, Topic topic)
        {
            Document dummyDoc = new Document();
            dummyDoc.RemoveAllChildren();
            dummyDoc.AppendChild(dummyDoc.ImportNode(section, true, ImportFormatMode.KeepSourceFormatting));

            dummyDoc.BuiltInDocumentProperties.Title = topic.Title;

            HtmlSaveOptions saveOptions = new HtmlSaveOptions();
            saveOptions.PrettyFormat = true;
            // This is to allow headings to appear to the left of main text.
            saveOptions.AllowNegativeLeftIndent = true;
            saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.None;

            dummyDoc.Save(topic.FileName, saveOptions);
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:20,代码来源:SplitIntoHtmlPages.cs

示例9: DocumentEnsureMinimum

        public void DocumentEnsureMinimum()
        {
            //ExStart
            //ExFor:Document.EnsureMinimum
            //ExSummary:Shows how to ensure the Document is valid (has the minimum nodes required to be valid).
            // Create a blank document then remove all nodes from it, the result will be a completely empty document.
            Document doc = new Document();
            doc.RemoveAllChildren();

            // Ensure that the document is valid. Since the document has no nodes this method will create an empty section
            // and add an empty paragraph to make it valid.
            doc.EnsureMinimum();
            //ExEnd
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:14,代码来源:ExDocument.cs

示例10: AppendDocumentFromAutomation

        public void AppendDocumentFromAutomation()
        {
            //ExStart
            //ExId:AppendDocumentFromAutomation
            //ExSummary:Shows how to join multiple documents together.
            // The document that the other documents will be appended to.
            Document doc = new Document();
            // We should call this method to clear this document of any existing content.
            doc.RemoveAllChildren();

            int recordCount = 5;
            for (int i = 1; i <= recordCount; i++)
            {
                // Open the document to join.
                Document srcDoc = new Document(@"C:\DetailsList.doc");

                // Append the source document at the end of the destination document.
                doc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);

                // In automation you were required to insert a new section break at this point, however in Aspose.Words we
                // don't need to do anything here as the appended document is imported as separate sectons already.

                // If this is the second document or above being appended then unlink all headers footers in this section
                // from the headers and footers of the previous section.
                if (i > 1)
                    doc.Sections[i].HeadersFooters.LinkToPrevious(false);
            }
            //ExEnd
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:29,代码来源:ExDocument.cs

示例11: CreateFromScratch

        public void CreateFromScratch()
        {
            //ExStart
            //ExFor:Node.GetText
            //ExFor:CompositeNode.RemoveAllChildren
            //ExFor:CompositeNode.AppendChild
            //ExFor:Section
            //ExFor:Section.#ctor
            //ExFor:Section.PageSetup
            //ExFor:PageSetup.SectionStart
            //ExFor:PageSetup.PaperSize
            //ExFor:SectionStart
            //ExFor:PaperSize
            //ExFor:Body
            //ExFor:Body.#ctor
            //ExFor:Paragraph
            //ExFor:Paragraph.#ctor
            //ExFor:Paragraph.ParagraphFormat
            //ExFor:ParagraphFormat
            //ExFor:ParagraphFormat.StyleName
            //ExFor:ParagraphFormat.Alignment
            //ExFor:ParagraphAlignment
            //ExFor:Run
            //ExFor:Run.#ctor(DocumentBase)
            //ExFor:Run.Text
            //ExFor:Inline.Font
            //ExSummary:Creates a simple document from scratch using the Aspose.Words object model.

            // Create an "empty" document. Note that like in Microsoft Word,
            // the empty document has one section, body and one paragraph in it.
            Document doc = new Document();

            // This truly makes the document empty. No sections (not possible in Microsoft Word).
            doc.RemoveAllChildren();

            // Create a new section node.
            // Note that the section has not yet been added to the document,
            // but we have to specify the parent document.
            Section section = new Section(doc);

            // Append the section to the document.
            doc.AppendChild(section);

            // Lets set some properties for the section.
            section.PageSetup.SectionStart = SectionStart.NewPage;
            section.PageSetup.PaperSize = PaperSize.Letter;

            // The section that we created is empty, lets populate it. The section needs at least the Body node.
            Body body = new Body(doc);
            section.AppendChild(body);

            // The body needs to have at least one paragraph.
            // Note that the paragraph has not yet been added to the document,
            // but we have to specify the parent document.
            // The parent document is needed so the paragraph can correctly work
            // with styles and other document-wide information.
            Paragraph para = new Paragraph(doc);
            body.AppendChild(para);

            // We can set some formatting for the paragraph
            para.ParagraphFormat.StyleName = "Heading 1";
            para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // So far we have one empty paragraph in the document.
            // The document is valid and can be saved, but lets add some text before saving.
            // Create a new run of text and add it to our paragraph.
            Run run = new Run(doc);
            run.Text = "Hello World!";
            run.Font.Color = System.Drawing.Color.Red;
            para.AppendChild(run);

            // As a matter of interest, you can retrieve text of the whole document and
            // see that \x000c is automatically appended. \x000c is the end of section character.
            Console.WriteLine("Hello World!\x000c", doc.GetText());

            // Save the document.
            doc.Save(MyDir + "Section.CreateFromScratch Out.doc");
            //ExEnd

            Assert.AreEqual("Hello World!\x000c", doc.GetText());
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:81,代码来源:ExSection.cs

示例12: InvioMessaggio


//.........这里部分代码省略.........
                        // ------------------------------------------
                        if (_fileSingolo == null)
                            _fileSingolo = new ZipFile();

                        nomeFile = persona != null ? $"{(_fileSingolo.Count + 1).ToString().PadLeft(3, '0')} - {persona.ID.ToString().PadLeft(8, '0')} - {persona.DisplayName}.zip"
                            : oggetto;
                        _fileSingolo.AddEntry(nomeFile, stream);
                        messaggio = stream.ToArray();
                    }
                    else
                    {
                        if (index > 0)
                        {
                            // Se è presente più di un allegato eseguo veramente un merge, altrimenti, per evitare problemi
                            // di orientamento e dimensione del pdf finale, se ho un solo allegato prendo questo come documento finale
                            if (index > 1)
                            {
                                if (parametriInvioLettera.FormatoDocumento == FormatoDocumentoEnum.Pdf)
                                {
                                    var pdfMerge = new PdfMerge { EnablePagination = parametriInvioLettera.RinumeraPagine };
                                    IList<byte[]> documenti = new List<byte[]>(contenutoAllegati.Length);
                                    for (var i = 0; i < index; i++)
                                    {
                                        if (nomiFiles[i].EndsWith(".pdf"))
                                            documenti.Add(contenutoAllegati[i]);
                                    }
                                    messaggio = pdfMerge.Merge(documenti, true);
                                }
                                else
                                {
                                    // The document that the other documents will be appended to.
                                    var doc = new Document();
                                    // We should call this method to clear this document of any existing content.
                                    doc.RemoveAllChildren();

                                    for (var i = 0; i < index; i++)
                                    {
                                        try
                                        {
                                            // Open the document to join.
                                            var srcDoc = new Document(new MemoryStream(contenutoAllegati[i]));

                                            // Append the source document at the end of the destination document.
                                            doc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);

                                            // In automation you were required to insert a new section break at this point, however in Aspose.Words we
                                            // don't need to do anything here as the appended document is imported as separate sectons already.

                                            // If this is the second document or above being appended then unlink all headers footers in this section
                                            // from the headers and footers of the previous section.
                                            if (i > 1)
                                                doc.Sections[i].HeadersFooters.LinkToPrevious(false);
                                        }
                                        catch (UnsupportedFileFormatException ex)
                                        {
                                            _log.WarnFormat("Documento con formato non riconosciuto - {0} - index:{1}", ex, Utility.GetMethodDescription(), index);
                                        }
                                    }

                                    var saveFormat = SaveFormat.Doc;
                                    if(parametriInvioLettera.FormatoDocumento == FormatoDocumentoEnum.Docx)
                                        saveFormat = SaveFormat.Docx;
                                    using (var stream = new MemoryStream())
                                    {
                                        doc.Save(stream, saveFormat);
                                        messaggio = stream.ToArray();
开发者ID:gipasoft,项目名称:Sfera,代码行数:67,代码来源:ManualeMessageService.cs


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