Exemplo n.º 1
0
        private void RenderPdfDocument(PdfDocument pdfDocument, bool preRender, PageSizeInfo pageSizeInfo, bool includeBackgroundObjects, bool portrait)
        {
            if (_preRendered && preRender)
            {
                throw new InvalidOperationException("Prerender has already been performed.");
            }

            var doc = GetDocument(preRender, portrait);

            var docRenderer = new DocumentRenderer(doc);

            docRenderer.PrepareDocument();

            for (var ii = 0; ii < doc.Sections.Count; ii++)
            {
                var page = AddPage(pdfDocument, pageSizeInfo, portrait);

                var gfx = _graphicsFactory.PrepareGraphics(page, docRenderer, ii);

                DoRenderStuff(gfx, new XRect(0, 0, page.Width, page.Height), preRender, ii, _template.SectionList.Sum(x => x.GetRenderPageCount()), includeBackgroundObjects, new XRect(0, 0, 0, 0));
            }

            if (preRender)
            {
                _preRendered = true;
            }
        }