#1 2024-09-10 16:33:21

Kaiser
Member
Registered: 2024-09-10
Posts: 4

Bookmarks example

I'd like to have an index in my PDF.
Is there an example of how to create it?
An example of the use of CreateBookMark?

Offline

#2 2024-09-13 12:19:32

rvk
Member
Registered: 2022-04-14
Posts: 115

Re: Bookmarks example

Do you mean the bookmarks at the right of the PDF?
Have you tried using CreateBookMark yet?

If you search on this forum there are several examples of CreateBookMark (just calling it after page creation).

Offline

#3 2024-09-13 15:53:22

Kaiser
Member
Registered: 2024-09-10
Posts: 4

Re: Bookmarks example

rvk wrote:

Do you mean the bookmarks at the right of the PDF?
Have you tried using CreateBookMark yet?

If you search on this forum there are several examples of CreateBookMark (just calling it after page creation).

Thanks for your reply.
Yes, I mean the bookmarks at the right of the PDF.
I will look into it and search for examples in this forum.

Offline

#4 2024-09-16 11:18:55

Kaiser
Member
Registered: 2024-09-10
Posts: 4

Re: Bookmarks example

I tried creating bookmarks:

var
  Doc  : TPdfDocumentGDI;
  Page : TPdfPage;
...
for i := 1 to PageCount do begin
  Page   := Doc.AddPage;
  PageNr := PageNr + 1;
  Doc.CreateBookMark(0, IntStr(PageNr));
  ...
end;

When I open the pdf, there are no bookmarks. Do I need to call another function to enable the bookmarks?

Last edited by Kaiser (2024-09-16 11:21:20)

Offline

#5 2024-10-30 09:09:04

Kaiser
Member
Registered: 2024-09-10
Posts: 4

Re: Bookmarks example

no one?

Offline

#6 2024-11-01 15:15:50

rvk
Member
Registered: 2022-04-14
Posts: 115

Re: Bookmarks example

Kaiser wrote:

I tried creating bookmarks:
...
When I open the pdf, there are no bookmarks. Do I need to call another function to enable the bookmarks?

Yeah... 'Bookmarks' is really confusing in PDF/Adobe. Although it's called Bookmarks in the sidebar, they are actually Outlines. It's also called outlines in the PDF specs, so looking for Bookmarks will only confuse you wink

If you do TPdfDocument.CreateOutline() you can create 'Bookmarks' in the PDF (also had to dive into the sourcecode to find that out wink ).

function TPdfDocument.CreateOutline(const Title: string; Level: integer; TopPosition: single): TPdfOutlineEntry;

You can create several levels. 0 is the root and 1 etc are levels under it.

For example:

// pdf.addpage etc
pdf.CreateOutline('Test-page-1- root', 0, 1);
pdf.CreateOutline('Sub bookmark', 1, 20{?});
// pdf.addpage etc
pdf.CreateOutline('Test-page-2-root', 0, 1);

BTW. You do need to use AUseOutlines to true when creating TPdfDocumentGDI, otherwise outline doesn't work.

pdf := TPdfDocumentGDI.Create(true); // <- AUseOutlines = true

Offline

Board footer

Powered by FluxBB