/** * Creates an page label dictionary for a document using the information in * the given COS dictionary. * * <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. * @param dict * an existing page label dictionary * @see org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels) * @throws IOException * If something goes wrong during the number tree conversion. */ public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException { this(document); if (dict == null) { return; } PDNumberTreeNode root = new PDNumberTreeNode(dict, PDPageLabelRange.class); findLabels(root); }
private void findLabels(PDNumberTreeNode node) throws IOException { if (node.getKids() != null) { List<PDNumberTreeNode> kids = node.getKids(); for (PDNumberTreeNode kid : kids) { findLabels(kid); } } else if (node.getNumbers() != null) { Map<Integer, COSObjectable> numbers = node.getNumbers(); for (Entry<Integer, COSObjectable> i : numbers.entrySet()) { if(i.getKey() >= 0) { labels.put(i.getKey(), (PDPageLabelRange) i.getValue()); } } } }
/** * Creates an page label dictionary for a document using the information in * the given COS dictionary. * * <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. * @param dict * an existing page label dictionary * @see org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels) * @throws IOException * If something goes wrong during the number tree conversion. */ public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException { this(document); if (dict == null) { return; } PDNumberTreeNode root = new PDNumberTreeNode(dict, PDPageLabelRange.class); findLabels(root); }
/** * Creates an page label dictionary for a document using the information in * the given COS dictionary. * * <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. * @param dict * an existing page label dictionary * @see org.apache.pdfbox.pdmodel.PDDocumentCatalog#setPageLabels(PDPageLabels) * @throws IOException * If something goes wrong during the number tree conversion. */ public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException { this(document); if (dict == null) { return; } PDNumberTreeNode root = new PDNumberTreeNode(dict, PDPageLabelRange.class); findLabels(root); }
private void findLabels(PDNumberTreeNode node) throws IOException { if (node.getKids() != null) { List<PDNumberTreeNode> kids = node.getKids(); for (PDNumberTreeNode kid : kids) { findLabels(kid); } } else if (node.getNumbers() != null) { Map<Integer, COSObjectable> numbers = node.getNumbers(); for (Entry<Integer, COSObjectable> i : numbers.entrySet()) { if(i.getKey() >= 0) { labels.put(i.getKey(), (PDPageLabelRange) i.getValue()); } } } }
private void findLabels(PDNumberTreeNode node) throws IOException { if (node.getKids() != null) { List<PDNumberTreeNode> kids = node.getKids(); for (PDNumberTreeNode kid : kids) { findLabels(kid); } } else if (node.getNumbers() != null) { Map<Integer, COSObjectable> numbers = node.getNumbers(); for (Entry<Integer, COSObjectable> i : numbers.entrySet()) { if(i.getKey() >= 0) { labels.put(i.getKey(), (PDPageLabelRange) i.getValue()); } } } }