0

We're trying to add bookmark or table of contents metadata to a PDF that is generated from HTML. How do you signal PDFBox/OpenHTMLtoPDF to create the bookmarks/TOC?

<div class="bkmrk0">Header One</div>
<div class="bkmrk1">Header Two for List</div>
...

<div class="bkmrk2">Header Three Text</div>
...

Bookmark example on left, TOC on right.

PDF Bookmarks Example

Omid Nazifi
  • 5,235
  • 8
  • 30
  • 56
ScrappyDev
  • 2,307
  • 8
  • 40
  • 60
  • Have you tried this? https://svn.apache.org/repos/asf/pdfbox/site/publish/userguide/bookmarks.html?p=1197837 – maio290 Jan 03 '19 at 16:23
  • I did see that, but that's for manually crating bookmarks. I need something more template driven. (see the answer below). – ScrappyDev Jan 03 '19 at 16:31

1 Answers1

0

To create Bookmarks:

<bookmarks>
 <bookmark name="Font Support" href="#fonts-feature-group"/>
 <bookmark name="RTL &amp; BIDI Text Support" href="#rtl-feature-group"/>
 <bookmark name="Forms Support" href="#forms-feature-group"/>
 <bookmark name="List Support" href="#lists-feature-group"/>
 <bookmark name="Z-Index Support" href="#z-index-feature-group"/>
 <bookmark name="SVG Support (Experimental)" href="#svg-feature-group"/>
</bookmarks>

The href is the id of the element where the bookmark should link to.

https://github.com/danfickle/openhtmltopdf/blob/14aef95364684fe3c7b7207bcb1246e5c3af0335/openhtmltopdf-examples/src/main/resources/visualtest/html/bookmark-head-nested.html

ScrappyDev
  • 2,307
  • 8
  • 40
  • 60