Пример #1
0
        public void TestGetCenterLeftRightSection()
        {
            HeaderFooterHelper helper = new HeaderFooterHelper();

            String headerFooter = "&CTest the center section";

            Assert.AreEqual("Test the center section", helper.GetCenterSection(headerFooter));

            headerFooter = "&CTest the center section&LThe left one&RAnd the right one";
            Assert.AreEqual("Test the center section", helper.GetCenterSection(headerFooter));
            Assert.AreEqual("The left one", helper.GetLeftSection(headerFooter));
            Assert.AreEqual("And the right one", helper.GetRightSection(headerFooter));
        }
Пример #2
0
        static void CreateBook()
        {
            var writer   = new PdfWriter(DEST);
            var pdf      = new PdfDocument(writer);
            var document = new Document(pdf, PageSize.A4);

            var chapter = string.Empty;

            document.SetMargins(50, 50, 50, 50);

            HeaderFooterHelper headerFooterHelper = new HeaderFooterHelper();
            DataTable          dtQuestions        = GetQuestions();
            Document           doc = new Document(pdf);

            for (var i = 0; i < dtQuestions.Rows.Count; i++)
            {
                Question q = new Question();
                q.Number  = Convert.ToInt32(dtQuestions.Rows[i]["Number"]);
                q.Content = dtQuestions.Rows[i]["Question"].ToString();
                document.Add(q.GetQuestion());

                Answer a = new Answer();
                a.Number  = Convert.ToInt32(dtQuestions.Rows[i]["Number"]);
                a.Content = dtQuestions.Rows[i]["Answer"].ToString();
                document.Add(a.GetAnswer());

                if (dtQuestions.Rows[i]["Title"] != DBNull.Value)
                {
                    Comment c = new Comment();
                    c.Title   = dtQuestions.Rows[i]["Title"].ToString();
                    c.Content = dtQuestions.Rows[i]["Comment"].ToString();
                    document.Add(c.GetComment());
                }

                chapter = dtQuestions.Rows[i]["Chapter"].ToString();

                headerFooterHelper.AddHeaderAndFooter(pdf, ref doc, $"The Golden Feedbacks 2018 - {dtQuestions.Rows[i]["Chapter"]}", 1, 2);
            }

            document.Close();
        }
Пример #3
0
        public void TestSetCenterLeftRightSection()
        {
            HeaderFooterHelper helper       = new HeaderFooterHelper();
            String             headerFooter = "";

            headerFooter = helper.SetCenterSection(headerFooter, "First Added center section");
            Assert.AreEqual("First Added center section", helper.GetCenterSection(headerFooter));
            headerFooter = helper.SetLeftSection(headerFooter, "First left");
            Assert.AreEqual("First left", helper.GetLeftSection(headerFooter));

            headerFooter = helper.SetRightSection(headerFooter, "First right");
            Assert.AreEqual("First right", helper.GetRightSection(headerFooter));
            Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right", headerFooter);

            headerFooter = helper.SetRightSection(headerFooter, "First right&F");
            Assert.AreEqual("First right&F", helper.GetRightSection(headerFooter));
            Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right&F", headerFooter);

            headerFooter = helper.SetRightSection(headerFooter, "First right&");
            Assert.AreEqual("First right&", helper.GetRightSection(headerFooter));
            Assert.AreEqual("&CFirst Added center section&LFirst left&RFirst right&", headerFooter);
        }
Пример #4
0
        /**
         * Create an instance of XSSFHeaderFooter from the supplied XML bean
         *
         * @param headerFooter
         */

        public XSSFHeaderFooter(CT_HeaderFooter headerFooter)
        {
            this.headerFooter = headerFooter;
            this.helper       = new HeaderFooterHelper();
        }