Пример #1
0
        public override string ToInnerPDF()
        {
            // 0 pages is possible
            //System.Diagnostics.Trace.Assert(_pages.Count > 0);

            PageLayout layout = new PageLayout();

            StringBuilder tmp = new StringBuilder();
            foreach (PDFPage page in _pages)
            {
                tmp.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{0} 0 R ", page.ObjectNumber);
            }

            string kids = string.Empty;
            if (tmp.Length > 0)
            {
                kids = string.Format(System.Globalization.CultureInfo.InvariantCulture, "/Kids[{0}]", tmp);
            }

            return string.Format(System.Globalization.CultureInfo.InvariantCulture, @"
            % PDFPages (
            {0} 0 obj
            <<
            /Type /Pages
            {1}
            /Count {2}
            /MediaBox [0 0 {3} {4}]
            >>
            endobj
            % )
            ", ObjectNumber, kids, _pages.Count, layout.Width, layout.Height);
        }
Пример #2
0
        public void Test3PagesPDF()
        {
            DataSet data = new DataSet("Sample");
            data.ReadXml("../../3pages.xml");

            PageLayout pageLayout = new PageLayout();
            pageLayout.RightHeader = "Current Date";
            Page.PageLayout = pageLayout;

            string tmp = PDFWriter.GetPDF(data);

            StreamWriter fileWriter = new StreamWriter("../../3pages_generated.pdf");
            fileWriter.Write(tmp);
            fileWriter.Close();

            StreamReader file = new StreamReader("../../3pages.pdf");
            string pdf = file.ReadToEnd();
            file.Close();

            Assert.AreEqual(pdf, tmp);
        }