pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Vacondio <andrea.vacon...@gmail.com>
Subject Re: Outline and outline items count
Date Tue, 10 Feb 2015 16:13:49 GMT
>Hmm... I haven't tested your code, but I wonder why root.getOpenCount()
always gets negative >numbers (= closed), and outline positive ones ( =
open)?
Outline has always positives because according to table 152 Count is "Total
number of visible outline items at all levels of the outline. The value
cannot be negative."
Root is the first outline item and is negative as long as it's closed (the
implementation makes newly created items closed by default). Table 153 says
"If the outline item is closed, Count is negative and its absolute value is
the number of descendants that would be visible if the outline item were
opened".
Does it make sense?

>What you could also try is to attach this to a PDF, and then test that one
with preflight-app and >with
http://www.pdf-tools.com/pdf/validate-pdfa-online.aspx . Both do also check
the outlines, >even if it isn't a valid pdf/a.
Ok, I'll test the current implementation and my implementation and see the
result.
Thanks


Am 09.02.2015 um 18:52 schrieb Andrea Vacondio:

> 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