Пример #1
0
        public void FootnoteOptions()
        {
            //ExStart
            //ExFor:PageSetup.EndnoteOptions
            //ExFor:PageSetup.FootnoteOptions
            //ExSummary:Shows how to configure options affecting footnotes/endnotes in a section.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Hello world!");
            builder.InsertFootnote(FootnoteType.Footnote, "Footnote reference text.");

            // Configure all footnotes in the first section to restart the numbering from 1
            // at each new page and display themselves directly beneath the text on every page.
            FootnoteOptions footnoteOptions = doc.Sections[0].PageSetup.FootnoteOptions;

            footnoteOptions.Position    = FootnotePosition.BeneathText;
            footnoteOptions.RestartRule = FootnoteNumberingRule.RestartPage;
            footnoteOptions.StartNumber = 1;

            builder.Write(" Hello again.");
            builder.InsertFootnote(FootnoteType.Footnote, "Endnote reference text.");

            // Configure all endnotes in the first section to maintain a continuous count throughout the section,
            // starting from 1. Also, set them all to appear collected at the end of the document.
            EndnoteOptions endnoteOptions = doc.Sections[0].PageSetup.EndnoteOptions;

            endnoteOptions.Position    = EndnotePosition.EndOfDocument;
            endnoteOptions.RestartRule = FootnoteNumberingRule.Continuous;
            endnoteOptions.StartNumber = 1;

            doc.Save(ArtifactsDir + "PageSetup.FootnoteOptions.docx");
            //ExEnd

            doc             = new Document(ArtifactsDir + "PageSetup.FootnoteOptions.docx");
            footnoteOptions = doc.FirstSection.PageSetup.FootnoteOptions;

            Assert.AreEqual(FootnotePosition.BeneathText, footnoteOptions.Position);
            Assert.AreEqual(FootnoteNumberingRule.RestartPage, footnoteOptions.RestartRule);
            Assert.AreEqual(1, footnoteOptions.StartNumber);

            endnoteOptions = doc.FirstSection.PageSetup.EndnoteOptions;

            Assert.AreEqual(EndnotePosition.EndOfDocument, endnoteOptions.Position);
            Assert.AreEqual(FootnoteNumberingRule.Continuous, endnoteOptions.RestartRule);
            Assert.AreEqual(1, endnoteOptions.StartNumber);
        }
Пример #2
0
        public void FootnoteOptions()
        {
            //ExStart
            //ExFor:PageSetup.EndnoteOptions
            //ExFor:PageSetup.FootnoteOptions
            //ExSummary:Shows how to set options for footnotes and endnotes in current section.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert text and a reference for it in the form of a footnote
            builder.Write("Hello world!.");
            builder.InsertFootnote(FootnoteType.Footnote, "Footnote reference text.");

            // Set options for footnote position and numbering
            FootnoteOptions footnoteOptions = doc.Sections[0].PageSetup.FootnoteOptions;

            footnoteOptions.Position    = FootnotePosition.BeneathText;
            footnoteOptions.RestartRule = FootnoteNumberingRule.RestartPage;
            footnoteOptions.StartNumber = 1;

            // Endnotes also have a similar options object
            builder.Write(" Hello again.");
            builder.InsertFootnote(FootnoteType.Footnote, "Endnote reference text.");

            EndnoteOptions endnoteOptions = doc.Sections[0].PageSetup.EndnoteOptions;

            endnoteOptions.Position    = EndnotePosition.EndOfDocument;
            endnoteOptions.RestartRule = FootnoteNumberingRule.Continuous;
            endnoteOptions.StartNumber = 1;

            doc.Save(ArtifactsDir + "PageSetup.FootnoteOptions.docx");
            //ExEnd

            doc             = new Document(ArtifactsDir + "PageSetup.FootnoteOptions.docx");
            footnoteOptions = doc.FirstSection.PageSetup.FootnoteOptions;

            Assert.AreEqual(FootnotePosition.BeneathText, footnoteOptions.Position);
            Assert.AreEqual(FootnoteNumberingRule.RestartPage, footnoteOptions.RestartRule);
            Assert.AreEqual(1, footnoteOptions.StartNumber);

            endnoteOptions = doc.FirstSection.PageSetup.EndnoteOptions;

            Assert.AreEqual(EndnotePosition.EndOfDocument, endnoteOptions.Position);
            Assert.AreEqual(FootnoteNumberingRule.Continuous, endnoteOptions.RestartRule);
            Assert.AreEqual(1, endnoteOptions.StartNumber);
        }
Пример #3
0
        public void SetEndnoteOptions()
        {
            //ExStart:SetEndnoteOptions
            Document        doc     = new Document(MyDir + "Document.docx");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Some text");
            builder.InsertFootnote(FootnoteType.Endnote, "Footnote text.");

            EndnoteOptions option = doc.EndnoteOptions;

            option.RestartRule = FootnoteNumberingRule.RestartPage;
            option.Position    = EndnotePosition.EndOfSection;

            doc.Save(ArtifactsDir + "WorkingWithFootnotes.SetEndnoteOptions.docx");
            //ExEnd:SetEndnoteOptions
        }
        private static void SetEndnoteOptions(string dataDir)
        {
            // ExStart:SetEndnoteOptions
            Document doc = new Document(dataDir + "TestFile.docx");

            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Some text");

            builder.InsertFootnote(FootnoteType.Endnote, "Eootnote text.");

            EndnoteOptions option = doc.EndnoteOptions;

            option.RestartRule = FootnoteNumberingRule.RestartPage;
            option.Position    = EndnotePosition.EndOfSection;

            dataDir = dataDir + "TestFile_Out.doc";

            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:SetEndnoteOptions
            Console.WriteLine("\nEootnote is inserted at the end of section successfully.\nFile saved at " + dataDir);
        }