/** * 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 org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels)}. * </p> * * @param document * The document the page label dictionary is created for. * @see org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels) */ public PDPageLabels(PDDocument document) { labels = new TreeMap<>(); this.doc = document; PDPageLabelRange defaultRange = new PDPageLabelRange(); defaultRange.setStyle(PDPageLabelRange.STYLE_DECIMAL); labels.put(0, defaultRange); }
@Override 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(); }
@Override 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(); }
/** * 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 org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels)}. * </p> * * @param document * The document the page label dictionary is created for. * @see org.apache.pdfbox.pdmodel.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); }
@Override 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(); }
/** * 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 org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels)}. * </p> * * @param document * The document the page label dictionary is created for. * @see org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels) */ public PDPageLabels(PDDocument document) { labels = new TreeMap<>(); this.doc = document; PDPageLabelRange defaultRange = new PDPageLabelRange(); defaultRange.setStyle(PDPageLabelRange.STYLE_DECIMAL); labels.put(0, defaultRange); }