Class PdfPageLabels


  • public class PdfPageLabels
    extends java.lang.Object
    Page labels are used to identify each page visually on the screen or in print.
    • Field Detail

      • DECIMAL_ARABIC_NUMERALS

        public static final int DECIMAL_ARABIC_NUMERALS
        Logical pages will have the form 1,2,3,...
        See Also:
        Constant Field Values
      • UPPERCASE_ROMAN_NUMERALS

        public static final int UPPERCASE_ROMAN_NUMERALS
        Logical pages will have the form I,II,III,IV,...
        See Also:
        Constant Field Values
      • LOWERCASE_ROMAN_NUMERALS

        public static final int LOWERCASE_ROMAN_NUMERALS
        Logical pages will have the form i,ii,iii,iv,...
        See Also:
        Constant Field Values
      • UPPERCASE_LETTERS

        public static final int UPPERCASE_LETTERS
        Logical pages will have the form of uppercase letters (A to Z for the first 26 pages, AA to ZZ for the next 26, and so on)
        See Also:
        Constant Field Values
      • LOWERCASE_LETTERS

        public static final int LOWERCASE_LETTERS
        Logical pages will have the form of uppercase letters (a to z for the first 26 pages, aa to zz for the next 26, and so on)
        See Also:
        Constant Field Values
      • EMPTY

        public static final int EMPTY
        No logical page numbers are generated but fixed text may still exist
        See Also:
        Constant Field Values
      • numberingStyle

        static PdfName[] numberingStyle
        Dictionary values to set the logical page styles
      • map

        private java.util.HashMap<java.lang.Integer,​PdfDictionary> map
        The sequence of logical pages. Will contain at least a value for page 1
    • Constructor Detail

      • PdfPageLabels

        public PdfPageLabels()
        Creates a new PdfPageLabel with a default logical page 1
    • Method Detail

      • addPageLabel

        public void addPageLabel​(int page,
                                 int numberStyle,
                                 java.lang.String text,
                                 int firstPage)
        Adds or replaces a page label.
        Parameters:
        page - the real page to start the numbering. First page is 1
        numberStyle - the numbering style such as LOWERCASE_ROMAN_NUMERALS
        text - the text to prefix the number. Can be null or empty
        firstPage - the first logical page number
      • addPageLabel

        public void addPageLabel​(int page,
                                 int numberStyle,
                                 java.lang.String text,
                                 int firstPage,
                                 boolean includeFirstPage)
        Adds or replaces a page label.
        Parameters:
        page - the real page to start the numbering. First page is 1
        numberStyle - the numbering style such as LOWERCASE_ROMAN_NUMERALS
        text - the text to prefix the number. Can be null or empty
        firstPage - the first logical page number
        includeFirstPage - If true, the page label will be added to the first page if it is page 1. If the first page is 1 and this value is false, the value will not be added to the dictionary.
      • addPageLabel

        public void addPageLabel​(int page,
                                 int numberStyle,
                                 java.lang.String text)
        Adds or replaces a page label. The first logical page has the default of 1.
        Parameters:
        page - the real page to start the numbering. First page is 1
        numberStyle - the numbering style such as LOWERCASE_ROMAN_NUMERALS
        text - the text to prefix the number. Can be null or empty
      • addPageLabel

        public void addPageLabel​(int page,
                                 int numberStyle)
        Adds or replaces a page label. There is no text prefix and the first logical page has the default of 1.
        Parameters:
        page - the real page to start the numbering. First page is 1
        numberStyle - the numbering style such as LOWERCASE_ROMAN_NUMERALS
      • removePageLabel

        public void removePageLabel​(int page)
        Removes a page label. The first page label can not be removed, only changed.
        Parameters:
        page - the real page to remove
      • getDictionary

        public PdfDictionary getDictionary​(PdfWriter writer)
        Gets the page label dictionary to insert into the document.
        Returns:
        the page label dictionary
      • getPageLabels

        public static java.lang.String[] getPageLabels​(PdfReader reader)
        Retrieves the page labels from a PDF as an array of String objects.
        Parameters:
        reader - a PdfReader object that has the page labels you want to retrieve
        Returns:
        a String array or null if no page labels are present
      • getPageLabelFormats

        public static PdfPageLabels.PdfPageLabelFormat[] getPageLabelFormats​(PdfReader reader)
        Retrieves the page labels from a PDF as an array of PdfPageLabels.PdfPageLabelFormat objects.
        Parameters:
        reader - a PdfReader object that has the page labels you want to retrieve
        Returns:
        a PdfPageLabelEntry array, containing an entry for each format change or null if no page labels are present