[ 
https://issues.apache.org/jira/browse/PDFBOX-856?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andreas Lehmkühler resolved PDFBOX-856.
---------------------------------------

    Resolution: Fixed
      Assignee: Andreas Lehmkühler

Thanks! I added the patch in revision 1023531

> NPE from PDPageLabels with a large number PDPageLabelRanges
> -----------------------------------------------------------
>
>                 Key: PDFBOX-856
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-856
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.2.1
>            Reporter: Kevin Jackson
>            Assignee: Andreas Lehmkühler
>
> 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()));
>             }
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to