pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Vacondio <andrea.vacon...@gmail.com>
Subject Outline and outline items count
Date Mon, 09 Feb 2015 17:52:08 GMT
Hi,
I'm playing with the outline package and I' trying to figure out if my
understanding of the spec tables 152 and 153, Count key for the outline
dictionary and outline item dictionary is correct. Could someone confirm
that the following units should pass?
Thanks

@Test
    public void outlinesCount()
    {
        PDDocumentOutline outline = new PDDocumentOutline();
        PDOutlineItem root = new PDOutlineItem();
        outline.appendChild(root);
        assertEquals(1, outline.getOpenCount());
        root.appendChild(new PDOutlineItem());
        assertEquals(-1, root.getOpenCount());
        assertEquals(1, outline.getOpenCount());
        root.appendChild(new PDOutlineItem());
        assertEquals(-2, root.getOpenCount());
        assertEquals(1, outline.getOpenCount());
        root.openNode();
        assertEquals(2, root.getOpenCount());
        assertEquals(3, outline.getOpenCount());
    }

 @Test
    public void multipleLevelsCount()
    {
        PDOutlineItem root = new PDOutlineItem();
        PDOutlineItem first = new PDOutlineItem();
        root.appendChild(first);
        assertEquals(-1, root.getOpenCount());
        PDOutlineItem second = new PDOutlineItem();
        root.appendChild(second);
        assertEquals(-2, root.getOpenCount());
        second.appendChild(new PDOutlineItem());
        assertEquals(-1, second.getOpenCount());
        assertEquals(-2, root.getOpenCount());
        second.openNode();
        assertEquals(1, second.getOpenCount());
        assertEquals(-3, root.getOpenCount());
        root.openNode();
        assertEquals(3, root.getOpenCount());
    }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message