Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - Create bookmark tree using Delphi
  FAQ FAQ  Forum Search   Register Register  Login Login

Create bookmark tree using Delphi

 Post Reply Post Reply
Author
Message
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 393
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Topic: Create bookmark tree using Delphi
    Posted: 27 Mar 12 at 8:50AM
This sample code has been contributed by a Quick PDF Library customer.

//=================== START  Delphi 7 OutLine Code

tvOutLine:TTreeView;

// calling code is: 
                  GetAllOutlines(nil, QP.GetFirstOutline, 1, 3);

// this function is only needed to get the selected page number when dblclicking on the node
function FindLastChar(const S: AnsiString; Ch: Char = #32): Integer;
asm
  test  eax, eax
  jz    @@30
  mov  ecx, [eax - 4]
  test  ecx, ecx
@@10:
  jz    @@30
  mov  dh, [eax + ecx]
  cmp  dl, dh
  jne  @@20
  mov  eax, ecx
  inc  eax
  ret
@@20:
  dec  ecx
  jmp  @@10
@@30:
  xor  eax, eax
  dec  eax
end;


procedure TfrmPdfReader.GetAllOutlines(nNode: TTreeNode; id, level, maxlevel: Integer);
var
  inPage, inID: Integer;
  rNode, cNode: TTreeNode;
begin
  if (level > maxlevel) then
    exit;
  while (id <> 0) do
  begin
    inPage := QP.GetOutlinePage(id);
    rNode := tvOutLine.Items.Add(nNode, QP.OutlineTitle(id) + ' ' + ' p.' + IntToStr(inPage));
    inID := QP.GetFirstChildOutline(ID);
    if (inID <> 0) then
    begin
      cNode := tvOutLine.Items.AddChild(rNode, QP.OutlineTitle(inid) + ' ' + ' p.' + IntToStr(inPage));
      GetAllOutlines(cNode, QP.GetFirstChildOutline(id), level + 1, maxlevel);
    end;
    id := QP.GetNextOutline(id);
  end;
end;

procedure TfrmPdfReader.tvOutlineDblClick(Sender: TObject);
var
  inPos, inPage: Integer;
  stPage: AnsiString;
begin
  inPos := FindLastChar(tvOutLine.Selected.Text, '.');
  stPage := copy(tvOutLine.Selected.Text, inPos + 1, 4);
  if TryStrToInt(stPage, inPage) then
    RenderPageToImage(QP,inPage,ImgPreview,ZoomPercentage: Integer);
end;

// ============= END Delphi Outline code  ===========
Back to Top
ginganinja1 View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Oct 12
Location: United Kingdom
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ginganinja1 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Oct 12 at 1:58PM
Hi

I was wondering if it was possible to make the page number displayed in the tree view invisible as I don't wont them to show as the page numbers on my bookmarks do not correspond the the page numbers displayed in the PDF document.

Thanks
Back to Top
Guy View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jun 16
Location: Australia
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guy Quote  Post ReplyReply Direct Link To This Post Posted: 21 Jul 16 at 5:09AM
Having a problem with this code...

It adds the first node of each parent twice...any clues.

Guy
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store