#1 2014-08-05 12:05:59

danclau
Member
Registered: 2014-08-05
Posts: 2

How to create bookmarks

Hi,

I would appreciate if somebody can share some code that shows how add bookmarks to a PDF file.

I already tried using this code, and many other variations (after adding a page), but it doesn't work:

          myPDF.CreateBookMark(0,'Page 3');
          arect.Left:=L;//L,T,B and R are the page margins
          arect.Top:=T;
          arect.Bottom:=T;
          arect.Right:=R;
          myPDF.CreateLink(arect,'Page 3');

After CreateBookmark failed I though I may create a link as well, but it is clear that I do not understand how to do it.

Thanks in advance.
Daniel

Offline

#2 2014-08-05 13:02:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: How to create bookmarks

The easiest is to use a TPdfDocumentGDI and render a metafile in which you have inserted bookmarks via GDICommentBookmark().

See for instance how mORMotReport.pas uses this function.

Offline

#3 2014-08-05 13:12:02

danclau
Member
Registered: 2014-08-05
Posts: 2

Re: How to create bookmarks

Thank you, but I'm just rendering bitmaps, not metafiles.

Offline

#4 2014-08-06 09:25:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: How to create bookmarks

You can take a look at TPdfEnum.HandleComment() for a low-level call to CreateBookMark() method.

Offline

Board footer

Powered by FluxBB