Package org.xhtmlrenderer.pdf
Class HTMLOutline
java.lang.Object
org.xhtmlrenderer.pdf.HTMLOutline
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ITextOutputDevice.Bookmark
private static final Pattern
private final int
private static final int
private final HTMLOutline
private static final Pattern
private static final Pattern
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
private
HTMLOutline
(int level, String name, HTMLOutline parent) -
Method Summary
Modifier and TypeMethodDescriptionstatic List<ITextOutputDevice.Bookmark>
Creates a bookmark list of the document outline generated for the given element context (usually the root document element).private static String
getBookmarkName
(Element element) private static String
getOutlineLevel
(Element element) (package private) static String
getOutlineLevelFromTagName
(String tagName) private static void
initBoxRefs
(Map<Element, ITextOutputDevice.Bookmark> map, Box box)
-
Field Details
-
HEADING
-
ROOT
-
WS
-
MAX_NAME_LENGTH
private static final int MAX_NAME_LENGTH- See Also:
-
parent
-
level
private final int level -
bookmark
-
-
Constructor Details
-
HTMLOutline
private HTMLOutline() -
HTMLOutline
-
-
Method Details
-
generate
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:
- Foo
- Bar
- Quux
- Thud
- Grunt
But it generates outline as:
- Foo
- Bar
- Quux
- Thud
- Grunt
- Thud
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:
- Foo
-
initBoxRefs
-
getBookmarkName
-
getOutlineLevel
-
getOutlineLevelFromTagName
-