List of usage examples for org.apache.pdfbox.pdmodel.common PDPageLabels PDPageLabels
public PDPageLabels(PDDocument document)
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); }/* www. j a v a2s . c o m*/ } doc.getDocumentCatalog().setPageLabels(pdPageLabels); doc.save(outputUri); doc.close(); } else { throw new IllegalArgumentException(Constants.ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE); } }