Tools to Capture and Convert the Web

How to add bookmarks or outlines to PDF Documents?

An item on a webpage loading after the main content

GrabzIt can automatically add bookmarks to a PDF document by using PDF’s built in outlining facility.

To do this specify the include outline parameter as shown below. The outline will then be automatically created by analysing the HTML of the web page for H2 and H3 elements to generate bookmarks with the text of these elements used for the bookmark names, additionally H3 elements will be automatically nested under H2 items in the bookmark list.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.IncludeOutline = true;
grabzIt.URLToPDF("http://www.google.com", options);
grabzIt.Save("http://www.mywebsite.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.setIncludeOutline(true);
grabzIt.URLToPDF("http://www.google.com", options);
grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/gh/GrabzIt/grabzit@js-3.2.9.9/javascript/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.google.com", 
{"format": "pdf", "download": 1, "includeoutline": 1}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"includeOutline":true};
client.url_to_pdf("http://www.google.com", options);
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = GrabzItPDFOptions->new();
$options->includeOutline(1);
$grabzIt->URLToPDF("http://www.google.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItPDFOptions();
$options->setIncludeOutline(true);
$grabzIt->URLToPDF("http://www.google.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItPDFOptions.GrabzItPDFOptions()
options.includeOutline = true
grabzIt.URLToPDF("http://www.google.com", options)
grabzIt.Save("http://www.mywebsite.com/handler.py")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::PDFOptions.new()
options.includeOutline = true
grabzIt.url_to_pdf("http://www.google.com", options)
grabzIt.save("http://www.mywebsite.com/handler/index")

Customizing Bookmarks and Outlines

Bookmarks can be customized by altering the HTML that is going to be converted to PDF. A H2 bookmark can be added to any element by giving it the GrabzItBookmarkH2 CSS class, similarly a H3 bookmark can be added to an element by assigning it the GrabzItBookmarkH3 CSS class. If you want to exclude an HTML element from being used as a bookmark you can assign the GrabzItBookmarkExclude class to the element. An example of using these special CSS classes to customize bookmarks is shown in the HTML below.

<html>
	<body>
		<h2 class="GrabzItBookmarkExclude">My Article</h2>
		<p>Ignorant branched humanity led now marianne too strongly entrance.</p>
		<span class="GrabzItBookmarkH2">Start here</span>
		<p>Rose to shew bore no ye of paid rent form.</p>
		<span class="GrabzItBookmarkH3">Then read this</span>
		<p>She which are maids boy sense her shade.</p>
	</body>
</html>
Back to SupportMore Web Capture ArticlesCommunity Web Capture Questions
Try all our premium features for free with a 7 day free trial. Then from $5.99 a month, unless cancelled.
  • More Captures
  • More Features
  • More API's
  • Bigger Scrapes
  • Bigger Captures
  • Bigger Everything
Start Free Trial