SharpPlot Reference > SharpPlot 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.



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


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);

... 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);

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,"");

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 ...

SharpPlot.RenderPdf Method

Send comments on this topic
© Dyalog Ltd 2021