예제 #1
0
        /// <summary>This method adds or replaces a page label.</summary>
        /// <param name="numberingStyle">
        /// The numbering style that shall be used for the numeric portion of each page label.
        /// May be NULL
        /// </param>
        /// <param name="labelPrefix">The label prefix for page labels in this range. May be NULL</param>
        /// <param name="firstPage">
        /// The value of the numeric portion for the first page label in the range. Must be greater or
        /// equal 1.
        /// </param>
        /// <returns/>
        public virtual iText.Kernel.Pdf.PdfPage SetPageLabel(PageLabelNumberingStyleConstants numberingStyle, String
                                                             labelPrefix, int firstPage)
        {
            if (firstPage < 1)
            {
                throw new PdfException(PdfException.InAPageLabelThePageNumbersMustBeGreaterOrEqualTo1);
            }
            PdfDictionary pageLabel = new PdfDictionary();

            if (numberingStyle != null)
            {
                switch (numberingStyle)
                {
                case PageLabelNumberingStyleConstants.DECIMAL_ARABIC_NUMERALS: {
                    pageLabel.Put(PdfName.S, PdfName.D);
                    break;
                }

                case PageLabelNumberingStyleConstants.UPPERCASE_ROMAN_NUMERALS: {
                    pageLabel.Put(PdfName.S, PdfName.R);
                    break;
                }

                case PageLabelNumberingStyleConstants.LOWERCASE_ROMAN_NUMERALS: {
                    pageLabel.Put(PdfName.S, PdfName.r);
                    break;
                }

                case PageLabelNumberingStyleConstants.UPPERCASE_LETTERS: {
                    pageLabel.Put(PdfName.S, PdfName.A);
                    break;
                }

                case PageLabelNumberingStyleConstants.LOWERCASE_LETTERS: {
                    pageLabel.Put(PdfName.S, PdfName.a);
                    break;
                }

                default: {
                    break;
                }
                }
            }
            if (labelPrefix != null)
            {
                pageLabel.Put(PdfName.P, new PdfString(labelPrefix));
            }
            if (firstPage != 1)
            {
                pageLabel.Put(PdfName.St, new PdfNumber(firstPage));
            }
            GetDocument().GetCatalog().GetPageLabelsTree(true).AddEntry(GetDocument().GetPageNumber(this) - 1, pageLabel
                                                                        );
            return(this);
        }
예제 #2
0
 /// <summary>This method adds or replaces a page label.</summary>
 /// <param name="numberingStyle">
 /// The numbering style that shall be used for the numeric portion of each page label.
 /// May be NULL
 /// </param>
 /// <param name="labelPrefix">The label prefix for page labels in this range. May be NULL</param>
 /// <returns/>
 public virtual iText.Kernel.Pdf.PdfPage SetPageLabel(PageLabelNumberingStyleConstants numberingStyle, String
                                                      labelPrefix)
 {
     return(SetPageLabel(numberingStyle, labelPrefix, 1));
 }