Example #1
0
        private static Section GetUniversitySection()
        {
            //Now starting with the real example
            var mainSec  = new Section($"Report for: {John.Name}");
            var persInfo = new Section("Personal Information", 2);

            mainSec.AddSection(persInfo);
            //Adding a pic with an external link (should works the same with an offline path)
            persInfo.Add(new Image("https://i.stack.imgur.com/l60Hf.png", "This should be a real pic", "Student photo", 100, 80));
            persInfo.AddParagraph();
            persInfo.AddQuote($"This is the profile pic of {John.Name}");
            //A paragraph with a on-a-fly italic word
            persInfo.AddParagraph("This personal information is automatically mapped in the List reading the properties of the " + TextFormat.Ital("Student") + " class");
            //Creating and auto-populating the Letterlist
            var autoLetterList = new NumberListAutoMap <Student>();

            autoLetterList.SetItem(John);
            //autoLetterList.Type = LetterType.LOWERCASE;
            persInfo.Add(autoLetterList);

            //Now to the auto-parsed Exams summary table
            var examsSummarySec = new Section("Exams summary", 2);

            mainSec.AddSection(examsSummarySec);
            examsSummarySec.AddParagraph("The following table is automatically mapped from the list of " + TextFormat.Ital("Exam"));
            var tableExams = new TableAutoMap <Exam>(Exams.ToArray()); //this table will auto detect property names

            tableExams.SetAlignement(TableAlignment.CENTER);           //this will set center for all the columns, you can set it for each every column
            examsSummarySec.Add(tableExams);

            //Last section: exams detail
            var examDetailsSec = new Section("Exams Detail", 2);

            mainSec.AddSection(examDetailsSec);
            examDetailsSec.AddParagraph("In this section we iterate over the list of exams and build a subsection of heading level 3 to have some details for each exam. I have also put an horizontal line between them.");
            var descTemplate = TemplateFromYaml.ReadFromYaml(EXAM_DETAIL_DESC_YAML);

            descTemplate.RenderMode = TemplateRenderMode.SINGLE;
            for (int i = 0; i < Exams.Count; i++)
            {
                var detailSec = new Section(Exams[i].Argument, 3);          //create subsection
                detailSec.AddParagraph("Chapters:");                        //adding a simple paragraph
                var chapList = new RomanList();                             //adding the chapter list
                foreach (string chapter in ExamsDetails[i].Chapters)
                {
                    chapList.AddItem(chapter);
                }
                detailSec.Add(chapList);
                descTemplate.ResultSingleID = Exams[i].Argument;    //choose the correct ID for the Result of the template
                detailSec.AddParagraph(descTemplate.Render());      //adding the rendered template as parahraph
                examDetailsSec.AddSection(detailSec);               //adding the subsection of level 3 to level 2
            }
            return(mainSec);
        }
Example #2
0
        private void AddTestGroupInfo()
        {
            m_Document.NewPage();

            //Добавление основного заголовка ONVIF TEST
            Paragraph title    = new Paragraph("ONVIF TEST", FontFactory.GetFont(FontFactory.TIMES, 18));
            Chapter   chapter2 = new Chapter(title, 2);

            //Для отсутсвия нумерации
            chapter2.NumberDepth = 0;
            Paragraph someText = new Paragraph("\n\n");

            chapter2.Add(someText);

            //Добавление группы тестов
            Paragraph title1   = new Paragraph("Device Discovery Test Cases", FontFactory.GetFont(FontFactory.TIMES, 18));
            Section   section1 = chapter2.AddSection(title1);

            section1.NumberDepth = 0;
            Paragraph someSectionText = new Paragraph("\n\n");

            section1.Add(someSectionText);

            //Добавление теста
            Paragraph title11 = new Paragraph("8.1.1 - MULTICAST NVT HELLO MESSAGE");
            //Добавление конечной точки для ссылки из содержания
            Anchor anc11 = new Anchor(".");

            anc11.Name = "MULTICAST NVT HELLO MESSAGE";
            title11.Add(anc11);
            Section section11 = section1.AddSection(title11);

            section11.NumberDepth = 0;
            Paragraph someSectionText11 = new Paragraph("Test Results\nTest Marked as Skipped\nSkipping all test steps\nTest complete\nTest SKIPPED\n\n");

            section11.Add(someSectionText11);

            //Добавление теста
            Paragraph title12 = new Paragraph("8.1.2 - MULTICAST NVT HELLO MESSAGE VALIDATION");
            Anchor    anc12   = new Anchor(".");

            anc12.Name = "MULTICAST NVT HELLO MESSAGE VALIDATION";
            title12.Add(anc12);
            Section section12 = section1.AddSection(title12);

            section12.NumberDepth = 0;
            Paragraph someSectionText12 = new Paragraph("Test Results\nTest Marked as Skipped\nSkipping all test steps\nTest complete\nTest SKIPPED\n\n");

            section12.Add(someSectionText12);


            m_Document.Add(chapter2);
        }
Example #3
0
        public void NullAssignmentShouldRemoveFirstSectionElement()
        {
            Section root   = new Section();
            Section child1 = new Section();
            Section child2 = new Section();

            root.AddSection("Dummy", child1);
            root.AddSection("Dummy", child2);
            root["Dummy"] = null;
            Assert.Equal(1, root.ElementCount);
            Assert.Equal(child2, (root["Dummy"] as SectionElement).Value);
        }
 public CreateSubSection(Section section, Paragraph title, int numberDepth)
 {
     title.Font.Size = 13;
     title.SetLeading(2.0f, 2.0f);
     title.SpacingAfter = 20f;
     subSection         = section.AddSection(20f, title, numberDepth);
 }
Example #5
0
// ---------------------------------------------------------------------------
        public void Write(Stream stream)
        {
            // step 1
            using (Document document = new Document()) {
                // step 2
                PdfWriter.GetInstance(document, stream);
                // step 3
                document.Open();
                // step 4
                int                 epoch       = -1;
                int                 currentYear = 0;
                Paragraph           title       = null;
                Chapter             chapter     = null;
                Section             section     = null;
                Section             subsection  = null;
                IEnumerable <Movie> movies      = PojoFactory.GetMovies(true);
                // loop over the movies
                foreach (Movie movie in movies)
                {
                    int yr = movie.Year;
                    // add the chapter if we're in a new epoch
                    if (epoch < (yr - 1940) / 10)
                    {
                        epoch = (yr - 1940) / 10;
                        if (chapter != null)
                        {
                            document.Add(chapter);
                        }
                        title   = new Paragraph(EPOCH[epoch], FONT[0]);
                        chapter = new Chapter(title, epoch + 1);
                    }
                    // switch to a new year
                    if (currentYear < yr)
                    {
                        currentYear = yr;
                        title       = new Paragraph(
                            string.Format("The year {0}", yr), FONT[1]
                            );
                        section = chapter.AddSection(title);
                        section.BookmarkTitle = yr.ToString();
                        section.Indentation   = 30;
                        section.BookmarkOpen  = false;
                        section.NumberStyle   = Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT;
                        section.Add(new Paragraph(
                                        string.Format("Movies from the year {0}:", yr)
                                        ));
                    }
                    title      = new Paragraph(movie.Title, FONT[2]);
                    subsection = section.AddSection(title);
                    subsection.IndentationLeft = 20;
                    subsection.NumberDepth     = 1;
                    subsection.Add(new Paragraph("Duration: " + movie.Duration.ToString(), FONT[3]));
                    subsection.Add(new Paragraph("Director(s):", FONT[3]));
                    subsection.Add(PojoToElementFactory.GetDirectorList(movie));
                    subsection.Add(new Paragraph("Countries:", FONT[3]));
                    subsection.Add(PojoToElementFactory.GetCountryList(movie));
                }
                document.Add(chapter);
            }
        }
Example #6
0
        public static Section GetSection(Section parent, Properties attributes)
        {
            Section section = parent.AddSection("");

            SetSectionParameters(section, attributes);
            return(section);
        }
Example #7
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);
        }
Example #8
0
        public void GetElementsShouldReturnSubSections()
        {
            Section root   = new Section();
            Section child1 = new Section();
            Section child2 = new Section();

            root.AddSection("Dummy", child1);
            root.AddSection("Dummy", child2);

            ElementCollection children = root.GetElements("Dummy");

            Assert.NotNull(children);
            Assert.Equal(2, children.Count);
            Assert.Equal(child1, (children[0] as SectionElement).Value);
            Assert.Equal(child2, (children[1] as SectionElement).Value);
        }
Example #9
0
        /// <summary>
        /// Adds test group info.
        /// </summary>
        private void AddTestGroupInfo()
        {
            Document.NewPage();

            Paragraph title   = new Paragraph("ONVIF TEST", FontFactory.GetFont(FontFactory.TIMES, 18));
            Chapter   chapter = new Chapter(title, 2);

            chapter.NumberDepth = 0;
            Paragraph empty = new Paragraph("\n\n");

            chapter.Add(empty);

            string  lastGroup = string.Empty;
            Section section   = null;

            foreach (TestInfo info in Log.TestResults.Keys.OrderBy(T => T.Category).ThenBy(TI => TI.Order))
            {
                string group = info.Group.Split('\\')[0];
                if (lastGroup != group)
                {
                    Paragraph groupTitle = new Paragraph(string.Format("\n\n{0}", group), FontFactory.GetFont(FontFactory.TIMES, 18));
                    section             = chapter.AddSection(groupTitle);
                    section.NumberDepth = 0;
                    Paragraph someSectionText = new Paragraph("\n");
                    section.Add(someSectionText);
                    lastGroup = group;
                }

                Paragraph testTitle = new Paragraph(info.Name);
                Anchor    ancor     = new Anchor(".");
                ancor.Name = info.Name;
                testTitle.Add(ancor);
                Section testSection = section.AddSection(testTitle);
                testSection.NumberDepth = 0;

                if (info.RequirementLevel == RequirementLevel.Optional)
                {
                    Paragraph optional = new Paragraph("* Optional Test");
                    testSection.Add(optional);
                }

                string testDescription = string.Empty;

                if (Log.TestResults.ContainsKey(info))
                {
                    testDescription = string.Format("\nTestResult\n{0}\n", Log.TestResults[info].ShortTextLog);
                    testDescription = testDescription.Replace(string.Format("{0}\r\n", info.Name), "");
                }
                else
                {
                    testDescription = "Test not run\n\n";
                }

                Paragraph sectionText = new Paragraph(testDescription, FontFactory.GetFont(FontFactory.TIMES, 11));
                testSection.Add(sectionText);
            }

            Document.Add(chapter);
        }
Example #10
0
        public void SubSectionShouldAddSectionElement()
        {
            Section root = new Section();

            root.AddSection("Dummy", new Section());

            Assert.NotNull(root["Dummy"]);
            Assert.IsType(typeof(SectionElement), root["Dummy"]);
        }
Example #11
0
        //REVIEW: Might be better to pass a filename/stream
        public void Open(String source)
        {
            elements = new Section();

            //REVIEW: Need to check for colons and newlines in comments
            char[] split = new char[] { ';', '\n' };

            Stack <Section> sections = new Stack <Section>();

            String  sectionType = "";
            Section curSection  = elements;

            int i = 0;

            while (i < source.Length)
            {
                int j = source.IndexOfAny(split, i);
                if (j == -1)
                {
                    break;
                }

                String line = source.Substring(i, j - i).Trim();
                if (source[j] == ';')
                {
                    curSection.AddElement(line);
                }
                else if (line.Length > 0)
                {
                    char firstChar = line[0];
                    if (firstChar == '{')
                    {
                        sections.Push(curSection);
                        Section newSection = new Section();
                        curSection.AddSection(sectionType, newSection);
                        curSection = newSection;
                    }
                    else if (firstChar == '}')
                    {
                        curSection = sections.Pop();
                    }
                    else
                    {
                        sectionType = line;
                    }
                }

                i = j + 1;
            }
        }
Example #12
0
        /// <summary>
        /// Build Section
        /// </summary>
        private void BuildSection(Document document, PdfWriter writer, PdfContentByte cb, Font font, List <ReportFileInfo> info, Section section, int sectionNum)
        {
            var subNum = sectionNum + 1;

            foreach (var subFile in info)
            {
                var subSection = section.AddSection(20f, new Paragraph(subFile.Name, GetFont()), subNum);
                BuildReportFile(document, writer, cb, subFile, subSection);
                if (!(subFile.SubFiles == null || subFile.SubFiles.Count == 0))
                {
                    BuildSection(document, writer, cb, font, subFile.SubFiles, subSection, subNum);
                }
            }
        }
        public static void ExportComputerSpecification(Chapter chapter, Font font, ComputerConfiguration computerInfo)
        {
            Section sectionPC = chapter.AddSection(new Paragraph("Computer specification.", font));

            sectionPC.Add(new Chunk("\n"));

            Section osSection = sectionPC.AddSection(new Paragraph("Operating System.", font));
            string  bits      = computerInfo.OperatingSystem.Is64bit ? " 64bit" : "32bit";

            osSection.Add(new Paragraph(String.Format("\t \t {0} {1}", computerInfo.OperatingSystem.Name, bits)));

            sectionPC.Add(new Chunk("\n"));

            Section processor = sectionPC.AddSection(new Paragraph("Processors.", font));

            foreach (var pr in computerInfo.Processors)
            {
                processor.Add(new Paragraph(String.Format("\t \t Name: {0}", pr.Name)));
                processor.Add(new Paragraph(String.Format("\t \t Threads: {0}", pr.Threads)));
                processor.Add(new Paragraph(String.Format("\t \t Max clock speed: {0} MHz", pr.MaxClockSpeed)));
            }

            sectionPC.Add(new Chunk("\n"));

            Section   memory = sectionPC.AddSection(new Paragraph("Memory modules.", font));
            PdfPTable table  = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Type"));
            table.AddCell(CreateHeaderPdfPCell("Capacity (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Speed (MHz)"));

            foreach (var mem in computerInfo.MemoryModules)
            {
                table.AddCell(new PdfPCell(new Phrase(mem.MemoryType.ToString())));
                table.AddCell(new PdfPCell(new Phrase(mem.Capacity.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
                table.AddCell(new PdfPCell(new Phrase(mem.Speed.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
            }

            memory.Add(new Chunk("\n"));
            memory.Add(table);

            sectionPC.Add(new Chunk("\n"));

            Section storage = sectionPC.AddSection(new Paragraph("Storages.", font));

            table = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Model"));
            table.AddCell(CreateHeaderPdfPCell("Size (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Partitions"));

            foreach (var stor in computerInfo.StorageDevices)
            {
                table.AddCell(new PdfPCell(new Phrase(stor.Model)));
                table.AddCell(new PdfPCell(new Phrase(stor.Size.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
                table.AddCell(new PdfPCell(new Phrase(string.Join(",", stor.DriveLetters.Select(x => x.Replace(":", ""))))));
            }

            storage.Add(new Chunk("\n"));
            storage.Add(table);
        }
Example #14
0
        public static void PageBookmark(Document pdf)
        {
            float indentation = 20;
            Font  _fontStyle  = FontFactory.GetFont("Tahoma", 8f, Font.ITALIC);
            Font  _linkStyle  = FontFactory.GetFont("Tahoma", 8f, Font.UNDERLINE, BaseColor.Blue);

            Chapter chapter1 = new Chapter(new Paragraph("Bookmarks and Links"), 1)
            {
                BookmarkTitle = "Text & co",
                BookmarkOpen  = true
            };

            chapter1.AddSection(indentation, "Section 1.1", 2);

            pdf.Add(chapter1);


            // Add a link to anchor
            var click = new Anchor("Click to an anchor-target in this document", _linkStyle)
            {
                Reference = "#target"
            };
            var paragraph1 = new Paragraph();

            paragraph1.IndentationLeft = indentation;
            paragraph1.Add(click);

            pdf.Add(paragraph1);


            // Add Paragraph
            var paragraph = new Paragraph(_lopsem, _fontStyle)
            {
                SpacingBefore   = 10f,
                SpacingAfter    = 10f,
                IndentationLeft = indentation,
                Alignment       = Element.ALIGN_JUSTIFIED
            };

            pdf.Add(paragraph);


            // Add simple Link
            Anchor link = new Anchor("www.sodeasoft.com", _linkStyle)
            {
                Reference = "https://www.sodeasoft.com"
            };
            var paragraph3 = new Paragraph("Web link : ", _fontStyle)
            {
                IndentationLeft = indentation
            };

            paragraph3.Add(link);

            pdf.Add(paragraph3);


            // To add paragraph and add at the end the link:
            // paragraph.Add(link);

            Section section2 = chapter1.AddSection(indentation, "Section 1.2", 2);

            {
                section2.TriggerNewPage = false;

                Section subsection1 = section2.AddSection(indentation, "Subsection 1.2.1", 3);
                Section subsection2 = section2.AddSection(20f, "Subsection 1.2.2", 3);
                subsection2.AddSection(indentation, "Sub Subsection 1.2.2.1", 4);
            }

            pdf.Add(section2);


            Chapter chapter2 = new Chapter(new Paragraph("This is Chapter 2"), 2)
            {
                BookmarkOpen   = false,
                TriggerNewPage = true
            };

            Section section3 = chapter2.AddSection("Section 2.1", 3);

            section3.AddSection("Subsection 2.1.1", 4);
            chapter2.AddSection("Section 2.2", 3);


            pdf.Add(chapter2);

            // Add the target from the Anchor above
            Anchor target = new Anchor("This is the Target");

            target.Name = "target";
            Paragraph paragraph2 = new Paragraph
            {
                target
            };

            pdf.Add(paragraph2);
        }
Example #15
0
    protected void ButtonCreate_Click(object sender, EventArgs e)
    {
        try
        {
            if (TextBoxAssessment.Text.Length > 0)
            {
                string assName = TextBoxAssessment.Text;
                int menuId = new CVTCMenu().GetMaxMenuID();
                menuId += 1;
                TextBoxAssessment.Text = "";
                Collection<CVTCMenu> menuList = new Collection<CVTCMenu>();
                CVTCMenu menu = null;
                Section section = new Section();

                Assessment ass = new Assessment();
                ass.AssessmentName = assName;
                ass.CreatedBy = 1;
                ass.CreatedDate = DateTime.Now;
                ass.LastModifiedBy = 1;
                ass.LastModifiedDate = DateTime.Now;
                ass.RefMenuID = menuId;
                ass.TotalFlag = 0;
                ass.TotalFlagPoint = 0;
                ass.TotalQuestion = 0;
                ass.TotalSection = 0;
                ass.AddAssessment();

                section.AssessmentOID = ass.AssessmentOID;
                section.SectionName = "NoScore";
                section.TotalQuestion = 0;
                section.TotalFlag = 0;
                section.Low = -1;
                section.Medium = -1;
                section.Flag = -1;
                section.High = -1;
                section.LastModifiedBy = 1;
                section.CreatedBy = 1;
                section.CreatedDate = DateTime.Now;
                section.LastModifiedDate = DateTime.Now;
                section.PassingTotal = -1;
                section.FlagPointTotal = -1;
                section.QuestionList = null;
                section.AddSection();

                #region Assign Value to Menu Items
                for (int i = menuId; i <= (menuId + 10); i++)
                {
                    menu = new CVTCMenu();
                    menu.MenuID = i;
                    if (menu.MenuID == menuId)
                    {
                        menu.NameMenu = assName;
                        menu.URL = " ";
                        menu.MenuLevel = 1;
                        menu.Parent = 24;
                        menu.IsExpanded = "false";
                        menu.IsLeave = "false";
                    }
                    if (menu.MenuID == (menuId + 1))
                    {

                        menu.NameMenu = "View Results";
                        menu.URL = "pg/assessment/Result.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 2))
                    {
                        menu.NameMenu = "Settings";
                        menu.URL = "pg/assessment/setting.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 3))
                    {
                        menu.NameMenu = "Reminder Email";
                        menu.URL = " ";
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "false";
                        menu.IsLeave = "false";
                    }
                    if (menu.MenuID == (menuId + 4))
                    {
                        menu.NameMenu = "Send Email";
                        menu.URL = "pg/assessment/ReminderEmail.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 3;
                        menu.Parent = (menuId + 3);
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 5))
                    {
                        menu.NameMenu = "Edit Term Codes";
                        menu.URL = "pg/assessment/editTermCodes.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 3;
                        menu.Parent = (menuId + 3);
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 6))
                    {
                        menu.NameMenu = "Results Email";
                        menu.URL = "pg/assessment/ResultEmail.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 7))
                    {
                        menu.NameMenu = "Results Letter";
                        menu.URL = "pg/assessment/ResultLetter.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 8))
                    {
                        menu.NameMenu = "Question Groups";
                        menu.URL = " ";
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "false";
                        menu.IsLeave = "false";
                    }
                    if (menu.MenuID == (menuId + 9))
                    {
                        menu.NameMenu = "Add";
                        menu.URL = "pg/assessment/SectionEdit.aspx?aid=" + ass.AssessmentOID.ToString();
                        menu.MenuLevel = 3;
                        menu.Parent = (menuId + 8);
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }
                    if (menu.MenuID == (menuId + 10))
                    {
                        menu.NameMenu = "No Score";
                        menu.URL = "pg/assessment/NoScore.aspx?soid=" + section.SectionOID.ToString();
                        menu.MenuLevel = 2;
                        menu.Parent = menuId;
                        menu.IsExpanded = "true";
                        menu.IsLeave = "true";
                    }

                    menuList.Add(menu);
                }
                #endregion

                //Save it to database
                foreach (CVTCMenu m in menuList)
                {
                    menu.SaveAssessmentMenuItem(m);
                }
                PopulateGrid();
                LabelMessage.Text = "Saved Successfully.";
            }
            else
            {
                LabelMessage.Text = "Please Enter Assessment Name.";
                TextBoxAssessment.Focus();
                return;
            }

            //ass.UpdateAssessmentRef();
        }
        catch (Exception ex)
        {

        }
    }
Example #16
0
 public static Section GetSection(Section parent, Properties attributes)
 {
     Section section = parent.AddSection("");
     SetSectionParameters(section, attributes);
     return section;
 }
Example #17
0
        public void CreateTaggedPdf11()
        {
            InitializeDocument("11");

            Chapter c =
                new Chapter(
                    new Paragraph("First chapter", new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLUE)),
                    1);

            c.TriggerNewPage = false;
            c.Indentation    = 40;
            Section s1 =
                c.AddSection(new Paragraph("First section of a first chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));

            s1.Indentation = 20;
            Section s2 =
                s1.AddSection(new Paragraph("First subsection of a first section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));

            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a first section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a first section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Second section of a first chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a second section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a second section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a second section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Third section of a first chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a third section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a third section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a third section of a first chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            document.Add(c);

            c =
                new Chapter(
                    new Paragraph("Second chapter", new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLUE)),
                    2);
            c.TriggerNewPage = false;
            c.Indentation    = 40;
            s1 =
                c.AddSection(new Paragraph("First section of a second chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a first section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a first section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a first section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Second section of a second chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a second section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a second section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a second section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Third section of a second chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a third section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a third section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a third section of a second chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            document.Add(c);

            c =
                new Chapter(
                    new Paragraph("Third chapter", new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLUE)),
                    3);
            c.TriggerNewPage = false;
            c.Indentation    = 40;
            s1 =
                c.AddSection(new Paragraph("First section of a third chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a first section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a first section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a first section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Second section of a third chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a second section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a second section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a second section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s1 =
                c.AddSection(new Paragraph("Third section of a third chapter",
                                           new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD, BaseColor.BLUE)));
            s1.Indentation = 20;
            s2             =
                s1.AddSection(new Paragraph("First subsection of a third section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Second subsection of a third section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            s2 =
                s1.AddSection(new Paragraph("Third subsection of a third section of a third chapter",
                                            new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE)));
            s2.Indentation = 10;
            s2.Add(new Paragraph("Some text..."));
            document.Add(c);

            document.Close();

            int[] nums = new int[] { 114, 60 };
            CheckNums(nums);
            CompareResults("11");
        }
Example #18
0
        public Chap0701()
        {
            Console.WriteLine("Chapter 7 example 1: my first XML");

            // step 1: creation of a document-object
            Document document = new Document();

            try
            {
                // step 2:
                // we create a writer that listens to the document
                // and directs a XML-stream to a file
                XmlWriter.GetInstance(document, new FileStream("Chap0701.xml", FileMode.Create), "itext.dtd");

                // step 3: we open the document
                document.Open();

                // step 4: we add content to the document
                Paragraph paragraph = new Paragraph("Please visit my ");
                Anchor    anchor1   = new Anchor("website (external reference)", FontFactory.GetFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255)));
                anchor1.Reference = "http://www.lowagie.com/iText/";
                anchor1.Name      = "top";
                paragraph.Add(anchor1);
                document.Add(paragraph);

                Paragraph entities = new Paragraph("These are some special characters: <, >, &, \" and '");
                document.Add(entities);

                document.Add(new Paragraph("some books I really like:"));
                List     list;
                ListItem listItem;
                list     = new List(true, 15);
                listItem = new ListItem("When Harlie was one", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12));
                listItem.Add(new Chunk(" by David Gerrold", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)).SetTextRise(8.0f));
                list.Add(listItem);
                listItem = new ListItem("The World according to Garp", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12));
                listItem.Add(new Chunk(" by John Irving", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)).SetTextRise(-8.0f));
                list.Add(listItem);
                listItem = new ListItem("Decamerone", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12));
                listItem.Add(new Chunk(" by Giovanni Boccaccio", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)));
                list.Add(listItem);
                document.Add(list);

                paragraph = new Paragraph("some movies I really like:");
                list      = new List(false, 10);
                list.Add("Wild At Heart");
                list.Add("Casablanca");
                list.Add("When Harry met Sally");
                list.Add("True Romance");
                list.Add("Le mari de la coiffeuse");
                paragraph.Add(list);
                document.Add(paragraph);

                document.Add(new Paragraph("Some authors I really like:"));
                list            = new List(false, 20);
                list.ListSymbol = new Chunk("*", FontFactory.GetFont(FontFactory.HELVETICA, 20, Font.BOLD));
                listItem        = new ListItem("Isaac Asimov");
                list.Add(listItem);
                List sublist;
                sublist            = new List(true, 10);
                sublist.ListSymbol = new Chunk("", FontFactory.GetFont(FontFactory.HELVETICA, 8));
                sublist.Add("The Foundation Trilogy");
                sublist.Add("The Complete Robot");
                sublist.Add("Caves of Steel");
                sublist.Add("The Naked Sun");
                list.Add(sublist);
                listItem = new ListItem("John Irving");
                list.Add(listItem);
                sublist            = new List(true, 10);
                sublist.ListSymbol = new Chunk("", FontFactory.GetFont(FontFactory.HELVETICA, 8));
                sublist.Add("The World according to Garp");
                sublist.Add("Hotel New Hampshire");
                sublist.Add("A prayer for Owen Meany");
                sublist.Add("Widow for a year");
                list.Add(sublist);
                listItem = new ListItem("Kurt Vonnegut");
                list.Add(listItem);
                sublist            = new List(true, 10);
                sublist.ListSymbol = new Chunk("", FontFactory.GetFont(FontFactory.HELVETICA, 8));
                sublist.Add("Slaughterhouse 5");
                sublist.Add("Welcome to the Monkey House");
                sublist.Add("The great pianola");
                sublist.Add("Galapagos");
                list.Add(sublist);
                document.Add(list);

                paragraph = new Paragraph("\n\n");
                document.Add(paragraph);

                Table table = new Table(3);
                table.BorderWidth = 1;
                table.BorderColor = new Color(0, 0, 255);
                table.Padding     = 5;
                table.Spacing     = 5;
                Cell cell = new Cell("header");
                cell.Header  = true;
                cell.Colspan = 3;
                table.AddCell(cell);
                table.EndHeaders();
                cell             = new Cell("example cell with colspan 1 and rowspan 2");
                cell.Rowspan     = 2;
                cell.BorderColor = new Color(255, 0, 0);
                table.AddCell(cell);
                table.AddCell("1.1");
                table.AddCell("2.1");
                table.AddCell("1.2");
                table.AddCell("2.2");
                table.AddCell("cell test1");
                cell         = new Cell("big cell");
                cell.Rowspan = 2;
                cell.Colspan = 2;
                table.AddCell(cell);
                table.AddCell("cell test2");
                document.Add(table);

                Image jpeg = Image.GetInstance("myKids.jpg");
                document.Add(jpeg);
                Image png = Image.GetInstance(new Uri("http://www.lowagie.com/iText/examples/hitchcock.png"));
                document.Add(png);
                Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.GetFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)));
                anchor2.Reference = "#top";
                document.Add(anchor2);

                document.Add(paragraph);

                // we define some fonts
                Font chapterFont    = FontFactory.GetFont(FontFactory.HELVETICA, 24, Font.NORMAL, new Color(255, 0, 0));
                Font sectionFont    = FontFactory.GetFont(FontFactory.HELVETICA, 20, Font.NORMAL, new Color(0, 0, 255));
                Font subsectionFont = FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64));
                // we create some paragraphs
                Paragraph blahblah     = new Paragraph("blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");
                Paragraph blahblahblah = new Paragraph("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");

                // this loop will create 7 chapters
                for (int i = 1; i < 8; i++)
                {
                    Paragraph cTitle  = new Paragraph("This is chapter " + i, chapterFont);
                    Chapter   chapter = new Chapter(cTitle, i);

                    if (i == 4)
                    {
                        blahblahblah.Alignment = Element.ALIGN_JUSTIFIED;
                        blahblah.Alignment     = Element.ALIGN_JUSTIFIED;
                        chapter.Add(blahblah);
                    }
                    if (i == 5)
                    {
                        blahblahblah.Alignment = Element.ALIGN_CENTER;
                        blahblah.Alignment     = Element.ALIGN_RIGHT;
                        chapter.Add(blahblah);
                    }
                    // add a table in the 6th chapter
                    if (i == 6)
                    {
                        blahblah.Alignment = Element.ALIGN_JUSTIFIED;
                        chapter.Add(table);
                    }
                    // in every chapter 3 sections will be added
                    for (int j = 1; j < 4; j++)
                    {
                        Paragraph sTitle  = new Paragraph("This is section " + j + " in chapter " + i, sectionFont);
                        Section   section = chapter.AddSection(sTitle, 1);
                        // in all chapters except the 1st one, some extra text is added to section 3
                        if (j == 3 && i > 1)
                        {
                            section.Add(blahblah);
                        }
                        // in every section 3 subsections are added
                        for (int k = 1; k < 4; k++)
                        {
                            Paragraph subTitle   = new Paragraph("This is subsection " + k + " of section " + j, subsectionFont);
                            Section   subsection = section.AddSection(subTitle, 3);
                            if (k == 1 && j == 3)
                            {
                                subsection.Add(blahblahblah);
                                subsection.Add(table);
                            }
                            subsection.Add(blahblah);
                        }
                        if (j == 2 && i > 2)
                        {
                            section.Add(blahblahblah);
                            section.Add(table);
                        }
                    }
                    document.Add(chapter);
                }
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            // step 5: we close the document
            document.Close();
        }
Example #19
0
        private void GenerateChapterHeader(string name, string chapterNumber, string alternateTitle, bool pageBreak, Document document)
        {
            var chapters = chapterNumber.Split('.');
            var level    = chapters.Count() - 1;

            var title = string.IsNullOrWhiteSpace(alternateTitle) ? name.ToUpper() : alternateTitle.ToUpper();
            var link  = EasyUtilities.SlugifyTitle(title);

            var chunk = new Chunk(title, _headerFonts[level]);

            chunk.SetLocalDestination(link);

            var header = new Paragraph(chunk)
            {
                SpacingBefore = _headerFonts[level].Size * 0.8f,
                SpacingAfter  = _headerFonts[level].Size * 0.8f
            };

            if (level == 0)
            {
                if (_parent != null && _hierarchy.Any())
                {
                    document.Add(_hierarchy.Last());
                }
                _hierarchy.Clear();

                var empty     = _pdfWriter.PageEmpty;
                var oddNumber = _pdfWriter.CurrentPageNumber % 2 == 1;

                if (!empty && oddNumber)
                {
                    document.Add(Chunk.NEXTPAGE);
                    _pdfWriter.PageEmpty = false;
                }
                else if (empty && !oddNumber)
                {
                    _pdfWriter.PageEmpty = false;
                }

                _parent = new iTextSharp.text.Chapter(header, int.Parse(chapters[0]));
            }
            else
            {
                if (pageBreak)
                {
                    document.Add(Chunk.NEXTPAGE);
                }

                if (level > _hierarchy.Count)
                {
                    _hierarchy.Push(_parent);
                }
                else
                {
                    while (_hierarchy.Count > level)
                    {
                        _parent = _hierarchy.Pop();
                    }
                    _parent = _hierarchy.Peek();
                }

                _parent             = _parent.AddSection(header);
                _parent.NumberStyle = Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT;
            }
        }
Example #20
0
        private Section CreateSection(Task task, Section parent)
        {
            Section section = null;

            if (parent == null)
            {
                section = new Chapter(CreateTitleElement(task), 0);
            }
            else
            {
                section = parent.AddSection(CreateTitleElement(task));
                section.TriggerNewPage = true;
            }

            section.NumberDepth   = 0;
            section.BookmarkTitle = GetTitle(task);
            section.BookmarkOpen  = true;

            // Create content
            if (m_AvailAttributes.Count > 0)
            {
                // Add spacer beneath title
                section.Add(Chunk.NEWLINE);

                foreach (var attrib in m_AvailAttributes)
                {
                    var attribVal = task.GetAttributeValue(attrib.Attribute, true, true);

                    if (!string.IsNullOrWhiteSpace(attribVal))
                    {
                        string html = FormatTextInputAsHtml(String.Format("{0}: {1}\n", attrib.Name, attribVal));
                        AddContent(html, section);
                    }
                }
            }

            // Comments is always last
            if (m_WantComments)
            {
                string html = task.GetHtmlComments();

                if (String.IsNullOrWhiteSpace(html))
                {
                    // Text comments
                    html = WebUtility.HtmlEncode(task.GetComments());

                    if (!String.IsNullOrWhiteSpace(html))
                    {
                        html = FormatTextInputAsHtml(html);
                    }
                }

                if (!String.IsNullOrWhiteSpace(html))
                {
                    // Add spacer before comments
                    section.Add(Chunk.NEWLINE);
                    AddContent(html, section);
                }
            }

            // Add subtasks as nested Sections on new pages
            var subtask = task.GetFirstSubtask();

            while (subtask.IsValid())
            {
                CreateSection(subtask, section);
                subtask = subtask.GetNextTask();
            }

            return(section);
        }
Example #21
0
 // ---------------------------------------------------------------------------
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter writer = PdfWriter.GetInstance(document, stream);
         // IMPORTANT: set linear page mode!
         writer.SetLinearPageMode();
         ChapterSectionTOC tevent = new ChapterSectionTOC(new MovieHistory1());
         writer.PageEvent = tevent;
         // step 3
         document.Open();
         // step 4
         int       epoch                 = -1;
         int       currentYear           = 0;
         Paragraph title                 = null;
         iTextSharp.text.Chapter chapter = null;
         Section section                 = null;
         Section subsection              = null;
         // add the chapters, sort by year
         foreach (Movie movie in PojoFactory.GetMovies(true))
         {
             int year = movie.Year;
             if (epoch < (year - 1940) / 10)
             {
                 epoch = (year - 1940) / 10;
                 if (chapter != null)
                 {
                     document.Add(chapter);
                 }
                 title   = new Paragraph(EPOCH[epoch], FONT[0]);
                 chapter = new iTextSharp.text.Chapter(title, epoch + 1);
             }
             if (currentYear < year)
             {
                 currentYear = year;
                 title       = new Paragraph(
                     String.Format("The year {0}", year), FONT[1]
                     );
                 section = chapter.AddSection(title);
                 section.BookmarkTitle = year.ToString();
                 section.Indentation   = 30;
                 section.BookmarkOpen  = false;
                 section.NumberStyle   = Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT;
                 section.Add(new Paragraph(
                                 String.Format("Movies from the year {0}:", year))
                             );
             }
             title      = new Paragraph(movie.MovieTitle, FONT[2]);
             subsection = section.AddSection(title);
             subsection.IndentationLeft = 20;
             subsection.NumberDepth     = 1;
             subsection.Add(new Paragraph(
                                "Duration: " + movie.Duration.ToString(), FONT[3]
                                ));
             subsection.Add(new Paragraph("Director(s):", FONT[3]));
             subsection.Add(PojoToElementFactory.GetDirectorList(movie));
             subsection.Add(new Paragraph("Countries:", FONT[3]));
             subsection.Add(PojoToElementFactory.GetCountryList(movie));
         }
         document.Add(chapter);
         // add the TOC starting on the next page
         document.NewPage();
         int toc = writer.PageNumber;
         foreach (Paragraph p in tevent.titles)
         {
             document.Add(p);
         }
         // always go to a new page before reordering pages.
         document.NewPage();
         // get the total number of pages that needs to be reordered
         int total = writer.ReorderPages(null);
         // change the order
         int[] order = new int[total];
         for (int i = 0; i < total; i++)
         {
             order[i] = i + toc;
             if (order[i] > total)
             {
                 order[i] -= total;
             }
         }
         // apply the new order
         writer.ReorderPages(order);
     }
 }
Example #22
0
 // ---------------------------------------------------------------------------
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document(PageSize.A4, 36, 36, 54, 54))
     {
         // step 2
         PdfWriter    writer = PdfWriter.GetInstance(document, stream);
         HeaderFooter tevent = new HeaderFooter();
         writer.SetBoxSize("art", new Rectangle(36, 54, 559, 788));
         writer.PageEvent = tevent;
         // step 3
         document.Open();
         // step 4
         int       epoch                 = -1;
         int       currentYear           = 0;
         Paragraph title                 = null;
         iTextSharp.text.Chapter chapter = null;
         Section section                 = null;
         Section subsection              = null;
         // add the chapters, sort by year
         foreach (Movie movie in PojoFactory.GetMovies(true))
         {
             int year = movie.Year;
             if (epoch < (year - 1940) / 10)
             {
                 epoch = (year - 1940) / 10;
                 if (chapter != null)
                 {
                     document.Add(chapter);
                 }
                 title   = new Paragraph(EPOCH[epoch], FONT[0]);
                 chapter = new iTextSharp.text.Chapter(title, epoch + 1);
             }
             if (currentYear < year)
             {
                 currentYear = year;
                 title       = new Paragraph(
                     String.Format("The year {0}", year), FONT[1]
                     );
                 section = chapter.AddSection(title);
                 section.BookmarkTitle = year.ToString();
                 section.Indentation   = 30;
                 section.BookmarkOpen  = false;
                 section.NumberStyle   = Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT;
                 section.Add(new Paragraph(
                                 String.Format("Movies from the year {0}:", year))
                             );
             }
             title      = new Paragraph(movie.MovieTitle, FONT[2]);
             subsection = section.AddSection(title);
             subsection.IndentationLeft = 20;
             subsection.NumberDepth     = 1;
             subsection.Add(new Paragraph(
                                "Duration: " + movie.Duration.ToString(), FONT[3]
                                ));
             subsection.Add(new Paragraph("Director(s):", FONT[3]));
             subsection.Add(PojoToElementFactory.GetDirectorList(movie));
             subsection.Add(new Paragraph("Countries:", FONT[3]));
             subsection.Add(PojoToElementFactory.GetCountryList(movie));
         }
         document.Add(chapter);
     }
 }
Example #23
0
        public Chap0402()
        {
            Console.WriteLine("Chapter 4 example 2: Chapters and Sections");

            // step 1: creation of a document-object
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);

            try
            {
                // step 2: we create a writer that listens to the document
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap0402.pdf", FileMode.Create));
                // step 3: we open the document
                document.Open();
                // step 4: we Add content to the document
                // we define some fonts
                Font chapterFont    = FontFactory.GetFont(FontFactory.HELVETICA, 24, Font.NORMAL, new Color(255, 0, 0));
                Font sectionFont    = FontFactory.GetFont(FontFactory.HELVETICA, 20, Font.NORMAL, new Color(0, 0, 255));
                Font subsectionFont = FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64));
                // we create some paragraphs
                Paragraph blahblah     = new Paragraph("blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");
                Paragraph blahblahblah = new Paragraph("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");
                // this loop will create 7 chapters
                for (int i = 1; i < 8; i++)
                {
                    Paragraph cTitle  = new Paragraph("This is chapter " + i, chapterFont);
                    Chapter   chapter = new Chapter(cTitle, i);

                    if (i == 4)
                    {
                        blahblahblah.Alignment = Element.ALIGN_JUSTIFIED;
                        blahblah.Alignment     = Element.ALIGN_JUSTIFIED;
                        chapter.Add(blahblah);
                    }
                    if (i == 5)
                    {
                        blahblahblah.Alignment = Element.ALIGN_CENTER;
                        blahblah.Alignment     = Element.ALIGN_RIGHT;
                        chapter.Add(blahblah);
                    }
                    // Add a table in the 6th chapter
                    if (i == 6)
                    {
                        blahblah.Alignment = Element.ALIGN_JUSTIFIED;
                    }
                    // in every chapter 3 sections will be Added
                    for (int j = 1; j < 4; j++)
                    {
                        Paragraph sTitle  = new Paragraph("This is section " + j + " in chapter " + i, sectionFont);
                        Section   section = chapter.AddSection(sTitle, 1);
                        // in all chapters except the 1st one, some extra text is Added to section 3
                        if (j == 3 && i > 1)
                        {
                            section.Add(blahblah);
                        }
                        // in every section 3 subsections are Added
                        for (int k = 1; k < 4; k++)
                        {
                            Paragraph subTitle   = new Paragraph("This is subsection " + k + " of section " + j, subsectionFont);
                            Section   subsection = section.AddSection(subTitle, 3);
                            if (k == 1 && j == 3)
                            {
                                subsection.Add(blahblahblah);
                            }
                            subsection.Add(blahblah);
                        }
                        if (j == 2 && i > 2)
                        {
                            section.Add(blahblahblah);
                        }
                    }
                    document.Add(chapter);
                }
            }
            catch (Exception de)
            {
                Console.Error.WriteLine(de.StackTrace);
            }
            // step 5: we close the document
            document.Close();
        }
Example #24
0
        /// <summary>
        /// Add Test, Test Case information to document
        /// </summary>
        /// <param name="myDocument">Document</param>
        /// <param name="Test">Test</param>
        /// <param name="section">Current Section</param>
        /// <param name="sectionNumber">Section Number</param>
        private void AddTestTestInfo(Document myDocument, ONVIF_TestCases.TestCases_Class.Test_Type Test, ref Section section, int sectionNumber)
        {
            int    x;
            Anchor anchor1;



            Paragraph subTitle = new Paragraph(Test.Number + " - " + Test.Name);

            // if building an index page add the anchor
            if (CreateIndex)
            {
                anchor1      = new Anchor(".");
                anchor1.Name = Test.Name;
                subTitle.Add(anchor1);
            }

            if (Test.Compliance == ONVIF_TestCases.TestCases_Class.TestCompliance.Optional)
            {
                subTitle.Add("*\n   *Optional Test");
            }

            Section subSection = section.AddSection(50f, subTitle, sectionNumber);

            subSection.BookmarkTitle = Test.Name;
            subSection.NumberDepth   = 0;


            //section1.Title = new Paragraph(Test.Name);

            myDocument.Add(subSection);

            //if (Test.Compliance == ONVIF_TestCases.TestCases_Class.TestCompliance.Optional)
            //{
            //    Paragraph p3 = new Paragraph(new Chunk("", FontFactory.GetFont(FontFactory.TIMES, 14)));
            //    p3.Add("OPTIONAL TEST\n");
            //    myDocument.Add(p3);
            //}

            // if this test wasn't run just indicate that to reduce confusion
            if (!Test.TestComplete)
            {
                myDocument.Add(new iTextSharp.text.Paragraph("Test not run"));
            }
            else
            {
                myDocument.Add(new iTextSharp.text.Paragraph("Test Results"));

                myDocument.Add(new iTextSharp.text.Paragraph(Test.Results));
                myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                if (verboseOutput)
                {
                    for (x = 0; x < Test.CurrentStep; x++)
                    {
                        //Paragraph subsubTitle = new Paragraph("Step " + (x + 1).ToString() + " information");
                        //Section subSection2 = subSection.AddSection(50f, subsubTitle, sectionNumber);
                        //myDocument.Add(subSection2);
                        Paragraph p0 = new Paragraph(new Chunk("Step " + (x + 1).ToString() + " information", FontFactory.GetFont(FontFactory.TIMES_BOLD, 14)));
                        myDocument.Add(p0);

                        //myDocument.Add(new iTextSharp.text.Paragraph("Step " + (x + 1).ToString() + " information"));
                        //myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));

                        if (Test.SoapError(x) != "")
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("Soap Errors"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Test.SoapError(x)));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }
                        else
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("No Soap Error received"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }

                        if (Test.SoapError(x) != "")
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("XML Errors"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Test.XML_Error(x)));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }
                        else
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("No XML Error received"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }

                        if (Test.XML_MessageSent(x) != "")
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("Message sent"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Test.XML_MessageSent(x)));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }
                        else
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("No Message sent"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }

                        if (Test.XML_MessageReceived(x) != "")
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("Message received"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Test.XML_MessageReceived(x)));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }
                        else
                        {
                            myDocument.Add(new iTextSharp.text.Paragraph("No Message received"));
                            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
                        }
                    }
                }
            }

            //myDocument.NewPage();


            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
            myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine));
        }
Example #25
0
    protected void ButtonSaveMyWork_Click(object sender, EventArgs e)
    {
        string ordNum = null, ques = null, RespAct = null, Resp = null, Flag = null,Reverse=null;
        int assessmentOID=0;
        Question questn;//=new Question();
        try
        {

            assessmentOID = (Session["aid"] != null) ? Convert.ToInt32(Session["aid"]) : -1;
            Collection<Question> quesList;// = new Collection<Question>();
            Collection<QuestionResponse> respList;//=new Collection<QuestionResponse>();

            QuestionResponse quesResp;
            Section section=new Section();
            section.SectionName = TextBoxSectionName.Text;
            section.AssessmentOID = assessmentOID;
            section.LastModifiedBy = 1;
            section.CreatedBy = 1;
            section.FlagPointTotal = 0;
            section.PassingTotal = 0;
            section.SectionOID = 0;
            section.TotalFlag = 0;
            section.TotalQuestion = 0;
            section.Flag =Convert.ToInt32( TextBoxFlag.Text);
            section.Low = Convert.ToInt32(TextBoxLow.Text);
            section.Medium = Convert.ToInt32(TextBoxMedium.Text);
            section.High = 67;

            #region Question

            //Loop For Questions
            quesList = new Collection<Question>();

            for(int i=1;;i+=6)
            {
                questn = new Question();
                ordNum = "TextOrderNumber" + i.ToString();

                if (ordNum==null )
                {
                    break;
                }
                ques = "TextQuestion" + i.ToString();
                RespAct = "SelectResponseAction" + i.ToString();

                //Loop For Question Responses

                respList = new Collection<QuestionResponse>();
                for (int j = 0; j < 6; j++)
                {
                    quesResp = new QuestionResponse();
                    Resp = "TextResponse" + (i+j).ToString();
                    Flag = "SelectFalgRating" + (i + j).ToString();

                    //Get Value From Form
                    Resp = Request.Form[Resp];
                    Flag = Request.Form[Flag];

                //Assign values Question Response

                quesResp.CreatedBy = 1;
                quesResp.LastModifiedBy = 1;
                quesResp.FlagRating = Convert.ToInt32(Flag);
                quesResp.Response = Resp;
                respList.Add(quesResp);

                }

                ordNum = Request.Form[ordNum];
                if (ordNum == null) break;
                ques = Request.Form[ques];
                RespAct = Request.Form[RespAct];

                //Assign Values to question
               // quesList= new Collection<Question>();
                //questn = new Question();
                questn.CreatedBy = 1;//Set current user
                questn.LastModifiedBy = 1;//Set current user
                questn.Keyword = " ";
                questn.MultipleAllow = 1;
                questn.OrderNo = Convert.ToInt32(ordNum);
                questn.QuestionText = ques;
                questn.RespAction = RespAct;

                Reverse = Convert.ToString("chkReverse" + i.ToString());
                Reverse = Request.Form[Reverse];
                if (Reverse == "on")
                {
                    questn.Reverse = 1;
                }
                else
                {
                    questn.Reverse = 0;
                }
                quesList.Add(questn);
                questn.QuestionRespList = respList;

            }

               #region dummy
                ////Process
                //for (int j = 1; ; j++)
                //{
                //    Resp = "TextResponse" + i.ToString() + "_" + j.ToString();
                //    Flag = "SelectFalgRating" + i.ToString() + "_" + j.ToString();

                //    Resp = Request.Form[Resp];
                //    Flag = Request.Form[Flag];
                //    if (Resp == null) break;

                //    //Assign values Question Response
                //    quesResp = new QuestionResponse();
                //    quesResp.CreatedBy = 1;
                //    quesResp.LastModifiedBy = 1;
                //    quesResp.FlagRating = Convert.ToInt32(Flag);
                //    quesResp.Response = Resp;
                //    respList.Add(quesResp);
                //}
                #endregion

        #endregion

            section.QuestionList = quesList;
            section.AddSection();
            section.UpdateAssessmentSection();
            TextBoxSectionName.Text = "";
            //TextBoxPassingTotal.Text = "0";
            TextBoxTotalQuestion.Text = "1";

            Assessment ass = new Assessment();
            ass = ass.GetAssessmentByOID(assessmentOID);

            CVTCMenu menu = new CVTCMenu();
            CVTCMenu tmp = menu.GetMenuByOID(ass.RefMenuID);
            menu.NameMenu = section.SectionName;

            int menuId = new CVTCMenu().GetMaxMenuID();
            menuId += 1;
            menu.MenuID = menuId;

            menu.URL = "pg/assessment/section.aspx?soid=" + section.SectionOID.ToString();
            menu.MenuLevel = 3;
            menu.Parent = tmp.MenuID+8;
            menu.IsExpanded = "true";
            menu.IsLeave = "true";

            menu.SaveAssessmentMenuItem(menu);

            LabelMessage.Text = "Saved Successfully.";

        }
        catch (Exception ex)
        {

        }
    }