mirror of
https://github.com/foliojs/pdfkit.git
synced 2026-01-25 16:06:44 +00:00
33 lines
3.3 KiB
HTML
33 lines
3.3 KiB
HTML
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Outlines in PDFKit</title><link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Code+Pro:400,700|Alegreya:700|Merriweather"><link rel="stylesheet" href="/docs/css/index.css"><link rel="stylesheet" href="/docs/css/github.css"></head><body><nav class="sidebar"><ul><li><a href="/">Home</a></li><li><a href="/docs/../index.html">Documentation</a><ul><li><a href="/docs/getting_started.html">Getting Started </a></li><li><a href="/docs/paper_sizes.html">Paper Sizes</a></li><li><a href="/docs/vector.html">Vector Graphics </a></li><li><a href="/docs/text.html">Text </a></li><li><a href="/docs/images.html">Images </a></li><li><a class="selected" href="/docs/outline.html">Outlines </a><ul><li><a href="#options">Options</a></li></ul></li><li><a href="/docs/annotations.html">Annotations </a></li><li><a href="/docs/forms.html">Forms </a></li><li><a href="/docs/destinations.html">Destinations</a></li><li><a href="/docs/attachments.html">Attachments </a></li><li><a href="/docs/accessibility.html">Accessibility</a></li><li><a href="/docs/you_made_it.html">You made it!</a></li></ul></li><li><a href="/docs/guide.pdf">PDF Guide</a></li><li><a href="/examples/kitchen-sink.pdf">Example PDF</a></li><li><a href="/demo/browser.html">Interactive Browser Demo</a></li><li><a href="http://github.com/foliojs/pdfkit">Source Code</a></li></ul></nav><div class="main"><h1 id="outlines_in_pdfkit">Outlines in PDFKit</h1>
|
|
|
|
<p>Outlines are the heirachical bookmarks that display in some PDF readers. Currently only page bookmarks are supported, but more may be added in the future. They are simple to add and only require a single method:</p>
|
|
|
|
<ul><li><code>addItem(title, options)</code></li></ul>
|
|
|
|
<p>Here is an example of adding a bookmark with a single child bookmark.</p>
|
|
|
|
<pre><code>// Get a reference to the Outline root
|
|
const { outline } = doc;
|
|
|
|
// Add a top-level bookmark
|
|
const top = outline.addItem('Top Level');
|
|
|
|
// Add a sub-section
|
|
top.addItem('Sub-section');</code></pre>
|
|
|
|
<h2 id="options">Options</h2>
|
|
|
|
<p>The <code>options</code> parameter currently only has one property: <code>expanded</code>. If this value is set to <code>true</code> then all of that section's children will be visible by default. This value defaults to <code>false</code>. </p>
|
|
|
|
<p>In this example the 'Top Level' section will be expanded to show 'Sub-section'.</p>
|
|
|
|
<pre><code>// Add a top-level bookmark
|
|
const top = outline.addItem('Top Level', { expanded: true });
|
|
|
|
// Add a sub-section
|
|
top.addItem('Sub-section');</code></pre><nav><a class="previous" href="/docs/images.html">Previous</a><a class="next" href="/docs/annotations.html">Next</a></nav></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script><script src="/docs/js/scroll.js"></script><script src="/docs/js/highlight.pack.js"></script><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
ga('create', 'UA-48340245-1', 'pdfkit.org');
|
|
ga('send', 'pageview');</script></body></html> |