Edit PDF outlines: text, color, action using JavaScript

To rename or edit an outline's color in an existing document.

JavaScript (v6.0+)

1<html>
2 <script src="../lib/core/CoreControls.js"></script>
3 <script src="../lib/core/pdf/PDFNet.js"></script>
4 <script>
5 (async function() {
6 CoreControls.setWorkerPath('../lib/core');
7 const doc = await PDFNet.PDFDoc.createFromURL(filename);
8 const root = await doc.getFirstBookmark();
9
10 // Rename outline
11 root.setTitle('new outline');
12
13 // Adding color to Outlines. Color and other formatting can help readers
14 // get around more easily in large PDF documents.
15 root.setColor(1, 0, 0);
16 })()
17 </script>
18</html>

Read, add, edit PDF outlines Full code sample which illustrates how to read and edit existing outline items and create new outlines using the high-level API

About editing an outline

The Outline API allows you to change any property on an outline item, including title text, action, color, and formatting. Color and other formatting can help readers navigate large PDF documents more easily. The above code renames an outline and also adjusts color and formatting properties on an Outline item.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales