Example #1
0
        private static Section GetIntroSection()
        {
            //Add the first section (the introduction one)
            var introSec = new Section("DocumentMaker example");
            //Load and modify the first paragraph
            string par1 = "Welcome to this example of a document rendered using DocumentMaker C# library";

            par1 = TextFormat.ReplaceItalic(par1, "DocumentMaker");
            introSec.AddParagraph(par1);
            introSec.AddHr();
            //The second paragraph is loaded from a txt file because it is always the same
            //and it is quite long
            introSec.AddParagraph(new FileInfo(INTRO_SECONDPARAGRAPH_FILE));

            //Now let's create the subsection "About the author", of heading level 2
            var aboutSec = new Section("About the author", 2);

            introSec.AddSection(aboutSec);  //appending this subsection to the first one
            //Adding the paragraph, changing a substring in italic
            aboutSec.AddParagraph(TextFormat.ReplaceItalic(File.ReadAllText(INTRO_ABOUT_FILE),
                                                           "DocumentMaker"));
            //The dot list with contact info will be manually assembled
            var contactInfos = new DotList();

            contactInfos.AddItem("Github profile: " + new DocLink("https://github.com/PaoloCattaneo92", "Github").Render()); //custom text
            contactInfos.AddItem("Mail: " + new MailToLink("*****@*****.**").Render());                          //this is used to correctly renders mailto addresses
            contactInfos.AddItem("Linkedin profile: " + new DocLink("https://www.linkedin.com/in/paolo-cattaneo-eng/", "Linkedin").Render());
            //Appending the dot list to the about section
            aboutSec.Add(contactInfos);
            return(introSec);
        }