Example usage for com.itextpdf.text.pdf PdfPageLabels addPageLabel

List of usage examples for com.itextpdf.text.pdf PdfPageLabels addPageLabel

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPageLabels addPageLabel.

Prototype

public void addPageLabel(int page, int numberStyle, String text, int firstPage) 

Source Link

Document

Adds or replaces a page label.

Usage

From source file:org.sejda.impl.itext5.util.PageLabelUtils.java

License:Open Source License

/**
 * Maps a map of {@link PdfPageLabel} to a {@link PdfPageLabels} instance that can be used as input for the PdfCopy.
 * /*from  www. j a  va  2  s  .  co  m*/
 * @param labels
 * @param totalPages
 * @return the resulting {@link PdfPageLabels}
 */
public static PdfPageLabels getLabels(Map<Integer, PdfPageLabel> labels, int totalPages) {
    PdfPageLabels retVal = new PdfPageLabels();
    for (Entry<Integer, PdfPageLabel> entry : labels.entrySet()) {
        PdfPageLabel label;
        if (entry.getKey() <= totalPages) {
            label = entry.getValue();
            retVal.addPageLabel(entry.getKey(), PAGE_NUMBERS_STYLES.get(label.getNumberingStyle()),
                    label.getLabelPrefix(), label.getLogicalPageNumber());
        } else {
            LOG.warn("Page number out of rage, {} will be ignored.", entry.getValue());
        }
    }
    return retVal;
}