/// <summary>
        /// Performs the layout of a single page, with header and footer generated and included as per the definition.
        /// Does not adjust the content size of the page
        /// </summary>
        protected void LayoutPageHeaderAndFooter()
        {
            IPDFTemplate headtemplate = this.GetCurrentHeaderTemplate(this.DocumentLayout.CurrentPageIndex);
            IPDFTemplate foottemplate = this.GetCurrentFooterTemplate(this.DocumentLayout.CurrentPageIndex);

            if (headtemplate != null)
            {
                PDFPageHeader header = new PDFPageHeader();
                this.Page.AddGeneratedHeader(header, this.DocumentLayout.CurrentPageIndex);
                //Create the content inside the header component
                InstantiateTemplateForPage(header, headtemplate);

                Style head = header.GetAppliedStyle();
                if (null != head)
                {
                    this.Context.StyleStack.Push(head);
                }

                Style full = this.Context.StyleStack.GetFullStyle(header);

                this.DocumentLayout.CurrentPage.BeginHeader(header, full, this.Context);

                header.RegisterPreLayout(this.Context);
                this.DoLayoutAChild(header);
                header.RegisterLayoutComplete(this.Context);

                this.DocumentLayout.CurrentPage.EndHeader();

                if (null != head)
                {
                    this.Context.StyleStack.Pop();
                }
            }

            if (foottemplate != null)
            {
                PDFPageFooter footer = new PDFPageFooter();
                this.Page.AddGeneratedFooter(footer, this.DocumentLayout.CurrentPageIndex);

                InstantiateTemplateForPage(footer, foottemplate);

                Style foot = footer.GetAppliedStyle();
                if (null != foot)
                {
                    this.Context.StyleStack.Push(foot);
                }

                Style full = this.Context.StyleStack.GetFullStyle(footer);


                this.DocumentLayout.CurrentPage.BeginFooter(footer, full, this.Context);

                footer.RegisterPreLayout(this.Context);
                this.DoLayoutAChild(footer);
                footer.RegisterLayoutComplete(this.Context);

                this.DocumentLayout.CurrentPage.EndFooter();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Begins a header on a the current document page
        /// </summary>
        public void BeginHeader(PDFPageHeader owner, Style full, PDFLayoutContext context)
        {
            if (null != this.HeaderBlock)
            {
                throw RecordAndRaise.LayoutException(Errors.AlreadyAHeaderDefinedOnPage);
            }

            PDFLayoutBlock block = new PDFLayoutBlock(this, owner, this.Engine, full, OverflowSplit.Never);

            //Take the magins away from the total bounds before initializing the regions
            PDFRect content = this.ContentBlock.TotalBounds;

            if (this.PositionOptions.Margins.IsEmpty == false)
            {
                content.Width  -= this.PositionOptions.Margins.Left + this.PositionOptions.Margins.Right;
                content.Height -= this.PositionOptions.Margins.Top + this.PositionOptions.Margins.Bottom;
            }

            block.InitRegions(content, this.ContentBlock.Position, full.CreateColumnOptions(), context);
            this._header = block;
            //Make this block current
            this.CurrentBlock = block;
        }