コード例 #1
0
 /**
  * Creates an empty page label dictionary for the given document.
  *
  * <p>Note that the page label dictionary won't be automatically added to the document; you will
  * still need to do it manually (see {@link PDDocumentCatalog#setPageLabels(PDPageLabels)}.
  *
  * @param document The document the page label dictionary is created for.
  * @see PDDocumentCatalog#setPageLabels(PDPageLabels)
  */
 public PDPageLabels(PDDocument document) {
   labels = new TreeMap<Integer, PDPageLabelRange>();
   this.doc = document;
   PDPageLabelRange defaultRange = new PDPageLabelRange();
   defaultRange.setStyle(PDPageLabelRange.STYLE_DECIMAL);
   labels.put(0, defaultRange);
 }
コード例 #2
0
 public String next() {
   if (!hasNext()) {
     throw new NoSuchElementException();
   }
   StringBuilder buf = new StringBuilder();
   if (labelInfo.getPrefix() != null) {
     String label = labelInfo.getPrefix();
     // there may be some labels with some null bytes at the end
     // which will lead to an incomplete output, see PDFBOX-1047
     while (label.lastIndexOf(0) != -1) {
       label = label.substring(0, label.length() - 1);
     }
     buf.append(label);
   }
   if (labelInfo.getStyle() != null) {
     buf.append(getNumber(labelInfo.getStart() + currentPage, labelInfo.getStyle()));
   }
   currentPage++;
   return buf.toString();
 }