// // public methods // #region public PDFLayoutPage BeginNewContinuationPage() /// <summary> /// Begins a new page based on the current page's size and content rect. This will then be the current page /// </summary> /// <returns></returns> public PDFLayoutPage BeginNewContinuationPage() { if (CurrentPageIndex < 0) { throw new ArgumentOutOfRangeException("Cannot begin a new page based on previous page if there are no previous pages"); } PDFLayoutPage pg = this.CurrentPage; PDFTraceLog log = this.DocumentComponent.TraceLog; if (log.ShouldLog(TraceLevel.Verbose)) { log.Add(TraceLevel.Verbose, "LAYOUT", "Beginning a new continuation page for '" + pg + "'"); } if (!pg.IsClosed) { pg.Close(); } PDFSize size = pg.Size; Style style = pg.FullStyle; Page owner = pg.Owner as Page; OverflowAction overflow = pg.OverflowAction; PDFLayoutPage newpg = this.BeginNewPage(owner, this.Engine, style, overflow); return(newpg); }
// // overrides // /// <summary> /// Main overridden method /// </summary> protected override void DoLayoutComponent() { IDisposable record = this.Context.PerformanceMonitor.Record(PerformanceMonitorType.Layout_Pages, "Page " + this.Component.ID); //Take a copy of the style stack for the header and footer this.PageStyleStack = this.Context.StyleStack.Clone(); //Get the page size and position options PageSize pgsize = this.FullStyle.CreatePageSize(); pgsize.Size = this.GetNextPageSize(this.Component, this.FullStyle, pgsize.Size); PDFPositionOptions options = this.FullStyle.CreatePostionOptions(); //Graphics PDFGraphics g = this.Page.CreateGraphics(this.StyleStack, this.Context); this.Context.Graphics = g; //Size, border, margins PDFRect bounds = new PDFRect(PDFPoint.Empty, pgsize.Size); PDFRect contentrect = GetContentRectFromBounds(bounds, options.Margins, options.Padding); //Columns PDFColumnOptions colOpts = this.FullStyle.CreateColumnOptions(); //Overflow OverflowAction action = options.OverflowAction; PDFLayoutPage pg = BuildNewPage(pgsize.Size, options, colOpts, action); //Register page numbering PDFPageNumberOptions numbers = this.GetPageNumbering(this.FullStyle); this.RegisterPageNumbering(pg, numbers); this.LayoutPageContent(); //close the last page PDFLayoutPage last = this.DocumentLayout.CurrentPage; if (last.IsClosed == false) { last.Close(); } //Unregister the page numbers. this.UnRegisterPageNumbering(last, numbers); //release graphics this.Context.Graphics = null; g.Dispose(); record.Dispose(); }
/// <summary> /// Checks the overflow style and if new pages are supported closes the current page layout and /// creates a new page layout (becomming the current page) and returns true. /// If overflow is not supported - returns false /// </summary> /// <param name="region">If there is a change in current page, this is set to the new region</param> /// <param name="block">If there is a change in current page, this is set to the new block</param> /// <returns></returns> public override bool MoveToNextPage(IPDFComponent initiator, Style initiatorStyle, Stack <PDFLayoutBlock> depth, ref PDFLayoutRegion region, ref PDFLayoutBlock block) { StyleValue <OverflowAction> action; if (this.FullStyle.TryGetValue(StyleKeys.OverflowActionKey, out action) && action.Value == OverflowAction.NewPage) { PDFLayoutPage lastpage = this.DocumentLayout.CurrentPage; PDFLayoutBlock open = lastpage.ContentBlock; if (open.IsClosed) { open = null; } else { open = open.LastOpenBlock(); } List <PDFLayoutBlock> toclose = new List <PDFLayoutBlock>(depth); for (int i = toclose.Count - 1; i >= 0; i--) { open = toclose[i]; if (open.CurrentRegion != null && open.CurrentRegion.IsClosed == false) { PDFLayoutRegion openRegion = open.CurrentRegion; openRegion.Close(); } PDFLayoutBlock parent = open.Parent as PDFLayoutBlock; if (null != parent) { PDFLayoutRegion parentRegion = parent.CurrentRegion; if (null != parentRegion) { open.Close(); parentRegion.AddToSize(open); } } //open = parent; } lastpage.Close(); var pgSize = this.GetNextPageSize(initiator, initiatorStyle, lastpage.Size); PDFLayoutPage page = BuildContinuationPage(lastpage, pgSize); block = page.CurrentBlock; region = block.CurrentRegion; if (this.Context.ShouldLogVerbose) { this.Context.TraceLog.Add(TraceLevel.Verbose, LOG_CATEGORY, "Built a new continuation page for " + this.Component + " and recreated the " + toclose.Count + " blocks and regions on the new page"); } return(true); } else { if (this.Context.ShouldLogVerbose) { this.Context.TraceLog.Add(TraceLevel.Verbose, LOG_CATEGORY, "Cannot overflow content for page " + this.Component + " halting the continued layout by returning false"); } return(false); //Cannot overflow } }