public void PageRomanLowerCollection() { int repeatcount = 20; //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 string[] expected = { "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx" }; PDFPageNumbers col = new PDFPageNumbers(); col.StartNumbering(null); Style full = new Style(); full.PageStyle.NumberStyle = PageNumberStyle.LowercaseRoman; PDFPageNumberOptions opts = full.CreatePageNumberOptions(); col.PushPageNumber(opts); col.Register(0); col.UnRegister(19); col.EndNumbering(); for (int i = 0; i < repeatcount; i++) { string actual = col.GetPageLabel(i); Assert.AreEqual(expected[i], actual); } }
public void Layout(PDFLayoutContext context, Styles.Style fullstyle) { bool first = true; PDFPageNumberOptions opts = fullstyle.CreatePageNumberOptions(); PDFPageNumberGroup grp = null; if (null != opts && opts.HasPageNumbering) { grp = context.DocumentLayout.Numbers.PushPageNumber(opts); } foreach (PageBase pg in this._group.Pages) { if (pg.Visible) { this.LayoutAPage(pg, first); first = false; } if (!this.ContinueLayout) { break; } } if (null != opts && opts.HasPageNumbering) { context.DocumentLayout.Numbers.PopNumberStyle(grp); } }
/// <summary> /// Registers the current page numbering options for the specified page at the specified index /// </summary> /// <param name="pageindex"></param> /// <param name="page"></param> /// <param name="num"></param> public PDFPageNumberGroup RegisterPageNumbering(int pageIndex, PDFPageNumberOptions options) { PDFPageNumberGroup grp = this.Numbers.PushPageNumber(options); this.Numbers.Register(pageIndex); return(grp); }
protected virtual void UnRegisterPageNumbering(PDFLayoutPage last, PDFPageNumberOptions options) { this.DocumentLayout.UnRegisterPageNumbering(last, _numbergroup); if (this.Context.ShouldLogDebug) { this.Context.TraceLog.Add(TraceLevel.Debug, LayoutEnginePage.LOG_CATEGORY, "Un-registered the page numbering"); } }
protected virtual void RegisterPageNumbering(PDFLayoutPage page, PDFPageNumberOptions options) { this._numbergroup = this.DocumentLayout.RegisterPageNumbering(page, options); _firstpageIndex = page.PageIndex; if (this.Context.ShouldLogDebug) { this.Context.TraceLog.Add(TraceLevel.Debug, LayoutEnginePage.LOG_CATEGORY, "Registered the page numbering"); } }
public void PageDecimalsCollection() { int repeatcount = 20; //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 string[] expected = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" }; PDFPageNumbers col = new PDFPageNumbers(); PDFPageNumberOptions options = new PDFPageNumberOptions() { NumberStyle = PageNumberStyle.Decimals }; col.StartNumbering(options); col.Register(0); for (int i = 0; i < repeatcount; i++) { string actual = col.GetPageLabel(i); Assert.AreEqual(expected[i], actual); } }
// // 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(); }
// // page numbers // #region public void StartPageNumbering(PDFPageNumberOptions opts) /// <summary> /// Called at the start of document layout to initialize the numbering collection /// </summary> /// <param name="style"></param> public void StartPageNumbering(PDFPageNumberOptions opts) { this._numbers = new PDFPageNumbers(); this._numbers.StartNumbering(opts); }