Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-856

NPE from PDPageLabels with a large number PDPageLabelRanges

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.1
    • 1.3.1
    • PDModel
    • None

    Description

      Section 3.8.6 states that number trees have either "Nums" or "Kids" entries. The current PDPageLabels does not handle Kids and fails with a NPE.

      Fix:

      public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException
      {
      this(document);
      if (dict == null)

      { return; }

      PDNumberTreeNode root = new PDNumberTreeNode(dict, COSDictionary.class);
      findLabels(root);
      }

      private void findLabels(PDNumberTreeNode node) throws IOException {
      if (node.getKids() != null) {
      @SuppressWarnings("unchecked")
      List<PDNumberTreeNode> kids = node.getKids();
      for (PDNumberTreeNode kid : kids)

      { findLabels(kid); }

      }
      else if (node.getNumbers() != null) {
      @SuppressWarnings("unchecked")
      Map<Integer, COSDictionary> numbers = node.getNumbers();
      for (Entry<Integer, COSDictionary> i : numbers.entrySet())

      { labels.put(i.getKey(), new PDPageLabelRange(i.getValue())); }

      }
      }

      Attachments

        Activity

          People

            lehmi Andreas Lehmkühler
            kevinjackson Kevin Jackson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: