示例#1
0
        /**
        * Initializes a page.
        * <P>
        * If the footer/header is set, it is printed.
        * @throws DocumentException on error
        */
        protected internal void InitPage()
        {
            // the pagenumber is incremented
            pageN++;

            // initialisation of some page objects
            annotationsImp.ResetAnnotations();
            pageResources = new PageResources();

            writer.ResetContent();
            graphics = new PdfContentByte(writer);
            text = new PdfContentByte(writer);
            text.Reset();
            text.BeginText();
            textEmptySize = text.Size;

            markPoint = 0;
            SetNewPageSizeAndMargins();
            imageEnd = -1;
            indentation.imageIndentRight = 0;
            indentation.imageIndentLeft = 0;
            indentation.indentBottom = 0;
            indentation.indentTop = 0;
            currentHeight = 0;

            // backgroundcolors, etc...
            thisBoxSize = new Hashtable(boxSize);
            if (pageSize.BackgroundColor != null
            || pageSize.HasBorders()
            || pageSize.BorderColor != null) {
                Add(pageSize);
            }

            float oldleading = leading;
            int oldAlignment = alignment;
            // if there is a footer, the footer is added
            DoFooter();
            // we move to the left/top position of the page
            text.MoveText(Left, Top);
            DoHeader();
            pageEmpty = true;
            // if there is an image waiting to be drawn, draw it
            if (imageWait != null) {
                Add(imageWait);
                imageWait = null;
            }
            leading = oldleading;
            alignment = oldAlignment;
            CarriageReturn();

            IPdfPageEvent pageEvent = writer.PageEvent;
            if (pageEvent != null) {
                if (firstPageEvent) {
                    pageEvent.OnOpenDocument(writer, this);
                }
                pageEvent.OnStartPage(writer, this);
            }
            firstPageEvent = false;
        }