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

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

Introduction

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

Prototype

public void setStyle(String style) 

Source Link

Document

Sets the numbering style for this page range.

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  ww  w  . j a v  a2s. co  m
        }

        doc.getDocumentCatalog().setPageLabels(pdPageLabels);

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

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