You are not logged in.
Pages: 1
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
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
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
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
no one?
Offline
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
If you do TPdfDocument.CreateOutline() you can create 'Bookmarks' in the PDF (also had to dive into the sourcecode to find that out ).
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
Pages: 1