Example usage for org.apache.pdfbox.pdmodel.common PDPageLabelRange PDPageLabelRange

List of usage examples for org.apache.pdfbox.pdmodel.common PDPageLabelRange PDPageLabelRange

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.common PDPageLabelRange PDPageLabelRange.

Prototype

public PDPageLabelRange() 

Source Link

Document

Creates a new empty page label range object.

Usage

From source file:org.pdfgal.pdfgal.pdfgal.impl.PDFGalImpl.java

License:Open Source License

@Override
public void reIndexPageNumbers(final String inputUri, final String outputUri,
        final List<PDFGalPageNumbering> pdfGalPageNumberingList) throws IOException, COSVisitorException {

    if (StringUtils.isNotBlank(inputUri) && StringUtils.isNotBlank(outputUri)
            && CollectionUtils.isNotEmpty(pdfGalPageNumberingList)) {

        final PDDocument doc = PDDocument.load(inputUri);

        final PDPageLabels pdPageLabels = new PDPageLabels(doc);

        for (final PDFGalPageNumbering pageNumbering : pdfGalPageNumberingList) {
            if (pageNumbering.isInitializated()) {
                final PDPageLabelRange pdPageLabelRange = new PDPageLabelRange();
                pdPageLabelRange.setStyle(pageNumbering.getNumberingStyle().getValue());
                pdPageLabels.setLabelItem(pageNumbering.getPageNumber() - 1, pdPageLabelRange);
            }//from  www.j  a v  a 2  s .  c o  m
        }

        doc.getDocumentCatalog().setPageLabels(pdPageLabels);

        doc.save(outputUri);
        doc.close();

    } else {
        throw new IllegalArgumentException(Constants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE);
    }
}