protected internal void SetNewPageSizeAndMargins() { pageSize = nextPageSize; if (marginMirroring && (PageNumber & 1) == 0) { marginRight = nextMarginLeft; marginLeft = nextMarginRight; } else { marginLeft = nextMarginLeft; marginRight = nextMarginRight; } if (marginMirroringTopBottom && (PageNumber & 1) == 0) { marginTop = nextMarginBottom; marginBottom = nextMarginTop; } else { marginTop = nextMarginTop; marginBottom = nextMarginBottom; } if (!IsTagged(writer)) { text = new PdfContentByte(writer); text.Reset(); } else { text = graphics; } text.BeginText(); // we move to the left/top position of the page text.MoveText(Left, Top); if (IsTagged(writer)) textEmptySize = text.Size; }
/** * 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; // we move to the left/top position of the page text.MoveText(Left, Top); 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; }