Class HTMLOutline

java.lang.Object
org.xhtmlrenderer.pdf.HTMLOutline

class HTMLOutline extends Object
  • Field Details

  • Constructor Details

    • HTMLOutline

      private HTMLOutline()
    • HTMLOutline

      private HTMLOutline(int level, String name, HTMLOutline parent)
  • Method Details

    • generate

      public static List<ITextOutputDevice.Bookmark> generate(Element context, Box box)
      Creates a bookmark list of the document outline generated for the given element context (usually the root document element).

      The current algorithm is more simple than the one suggested in the HTML5 specification such as it is not affected by sectioning content but just the heading level. For example:

       <body>
         <h1>Foo</h1>
         <h3>Bar</h3>
         <blockquote>
           <h5>Bla</h5>
         </blockquote>
         <p>Baz</p>
         <h2>Quux</h2>
         <section>
           <h3>Thud</h3>
         </section>
         <h4>Grunt</h4>
       </body>

      Should generate outline as:

      1. Foo
        1. Bar
        2. Quux
        3. Thud
        4. Grunt

      But it generates outline as:

      1. Foo
        1. Bar
        2. Quux
          1. Thud
            1. Grunt

      Example document customizations

      Include non-heading element as bookmark (level 4)
       <strong data-pdf-bookmark="4">Foo bar</strong>
      Specify bookmark name
       <tr data-pdf-bookmark="5" data-pdf-bookmark-name="Bar baz">...</tr>
      Exclude individual heading from bookmarks
       <h3 data-pdf-bookmark="none">Baz qux</h3>
      Prevent automatic bookmarks for the whole of the document
       <html data-pdf-bookmark="exclude">...</html>
      Parameters:
      context - the top element a sectioning outline would be generated for;
      box - box hierarchy the outline bookmarks would get mapped into.
      Returns:
      Bookmarks of the outline generated for the given element context.
      See Also:
    • initBoxRefs

      private static void initBoxRefs(Map<Element,ITextOutputDevice.Bookmark> map, Box box)
    • getBookmarkName

      private static String getBookmarkName(Element element)
    • getOutlineLevel

      private static String getOutlineLevel(Element element)
    • getOutlineLevelFromTagName

      static String getOutlineLevelFromTagName(String tagName)