Exemple #1
0
        /// <summary>
        /// Completes a sequence of pages and adds the registation of page numbers to this
        /// </summary>
        public void EndCounting()
        {
            if (!this.IsCounting)
            {
                throw new InvalidOperationException("This group is not currently counting - use the isCounting property to check");
            }

            NumberGroupSequence seq = this._currSequence;

            PDFPageNumberRegistration reg = new PDFPageNumberRegistration(seq.StartPageIndex, seq.EndPageIndex, this);

            //If we have an existing count to this group then we need to add the numbering offset to the sequence
            reg.PreviousLinkedRegistrationPageCount = this.GroupPageCount;

            this.Owner.Registrations.Add(reg);
            this.GroupPageCount += this._currSequence.SequencePageCount;
            this._currSequence   = null;
        }
        public PDFPageNumberData GetPageData(int pageindex)
        {
            PDFPageNumberRegistration reg = null;

            for (int i = 0; i < this._registrations.Count; i++)
            {
                reg = this._registrations[i];
                if (reg.IsClosed == false || reg.LastPageIndex >= pageindex)
                {
                    break;
                }
            }
            if (null == reg)
            {
                return(GetPageDataWithGroup(pageindex, this.CurrentGroup));
            }
            else
            {
                return(GetPageDataWithRegistration(pageindex, reg));
            };
        }
        private PDFPageNumberData GetPageDataWithRegistration(int pageindex, PDFPageNumberRegistration reg)
        {
            string label     = reg.GetPageLabel(pageindex);
            string lastLabel = reg.GetPageLabel(reg.LastPageIndex);

            int grpNum            = (pageindex - reg.FirstPageIndex) + 1;
            int lastGrpNum        = (reg.LastPageIndex - reg.FirstPageIndex) + 1;
            int globalPageNum     = pageindex + 1;
            int globalLastPageNum = _totalpages + 1;

            PDFPageNumberData data = new PDFPageNumberData(reg.Group)
            {
                Label           = label,
                LastLabel       = lastLabel,
                GroupNumber     = grpNum,
                GroupLastNumber = lastGrpNum,
                PageNumber      = globalPageNum,
                LastPageNumber  = globalLastPageNum
            };

            return(data);
        }