Reference > Methods > AddBookmark Method

SharpPlot.AddBookmark Method

Creates a bookmark at this point in the output stream. This will be used in PDF output to create an entry in the outline for the document.

Overloads

Example

sp.Reset(590,835); // Paper size
sp.AddBookmark("January 2006",0,true);

Description

Multi-page collections of charts may be bookmarked with easily recognised names which can be organised into a tree structure to be shown by the Acrobat Reader as ‘Outlines’. It is also possible to create entries in the outline tree which jump to external resources, typically webpages or other PDFs.

The simple form of the command is ...

sp.AddBookmark("Sales analysis");

The bookmark will be placed on the next chart to be generated – you may call sp.AddBookmark several times in succession to create an outline structure if required.

Making an indented outline for Acrobat Reader

The outline information is included in the PDF file generated using sp.RenderPdf. It will often be helpful to indicate the outline level of the bookmark, with major sections at level-0 and subsidiary sections indented to form a contents tree.

sp.AddBookmark("'Sales analysis",0);
sp.AddBookmark("Europe",1);
sp.DrawBarChart(arr_europe);
sp.NewPage();
sp.AddBookmark("Asia",1)
sp.DrawBarChart(arr_asia);

... and so on. This structure will then appear in the Acrobat Viewer outline bar to the left of the document. By default, sections will be closed on opening the document – you can force the Acrobat Viewer to open a section automatically by appending true as the third parameter to the bookmark call:

sp.AddBookmark("Profit and Loss",0,true);
sp.AddBookmark("Income breakdown",1,true);
sp.AddBookmark("Consulting",2);

Linking to webpages or other PDFs

You can add a link to an external resource by including a 4th element in the call, for example:

sp.AddBookmark("Home page",0,true,"http://www.grapl.com");

This will allow the user to click on the outline entry and automatically open a web-browser at the page you give. To have Acrobat Reader load another PDF, just use a filename here in place of the url.

See also ...

RenderPdf Method


Send comments on this topic
© Dyalog Ltd 2013