> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/outlines-bookmarks/add.md).

# Add an outline to PDFs using JavaScript

Easily enhance PDFs with outlines using JavaScript. Learn how to add structured navigation to your documents with this simple guide. The Apryse Web SDK streamlines secure, serverless document processi

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#PageManipulation" class="button primary">Package: Page Manipulation</a><a href="https://showcase.apryse.com/edit-table-of-contents-in-a-pdf" class="button primary">Live demo</a>
{% endhint %}

{% hint style="warning" %}
Make sure you have [Full API enabled in WebViewer.](/web/what-is-webviewer/full-api.md)
{% endhint %}

To add a new outline item in an existing document.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
Webviewer(...).then(async instance => {
  const { documentViewer, PDFNet } = instance.Core;
  await PDFNet.initialize();

  documentViewer.addEventListener('documentLoaded', async () => {
    const doc = documentViewer.getDocument();
    const pdfDoc = await doc.getPDFDoc();

    // create outline and add it to the first page
    const myitem = await PDFNet.Bookmark.create(pdfDoc, 'My outline');
    await myitem.setAction(await PDFNet.Action.createGoto(await PDFNet.Destination.createFit(await pdfDoc.getPage(1))));
    await pdfDoc.addRootBookmark(myitem);

    // refresh document outline
    instance.UI.reloadOutline();
  });
});
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
Webviewer(...).then(async instance => {
  const { docViewer, PDFNet } = instance;
  await PDFNet.initialize();

  docViewer.on('documentLoaded', () => {
    const doc = docViewer.getDocument();
    const pdfDoc = await doc.getPDFDoc();

    // create outline and add it to the first page
    const myitem = await PDFNet.Bookmark.create(pdfDoc, 'My outline');
    await myitem.setAction(await PDFNet.Action.createGoto(await PDFNet.Destination.createFit(await pdfDoc.getPage(1))));
    await pdfDoc.addRootBookmark(myitem);

    // refresh document outline
    const bookmarks = await doc.getBookmarks();
    instance.updateOutlines(bookmarks);
  });
});
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/outlines-bookmarks/add.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
