IPXC_Bookmark

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

IPXC_Bookmark

Post by jeffp »

Can you help me out with how to set a bookmark? I want to give the bookmark a title and the set it to a certain Page in the PDF.

Actually, it needs to be linked to the APage such that it will follow such PDF page in the event the Page gets reordered or inserted in another PDF.

This is where I'm stuck. I'm not sure if I'm creating this correctly.

Code: Select all

procedure TMyPDF.AddBookmark(APage: Integer; ATitle: String; APrepend: Boolean = False);
var
  BM: IPXC_Bookmark;
  AL: IPXC_ActionsList;
begin
  if Assigned(FDoc) then
  try
    FDoc.BookmarkRoot.AddNewChild(not APrepend, BM);
    BM.Set_Title(ATitle);
    //How do I set the Page??
    FDoc.BookmarkRoot.AddChild(BM, not APrepend);
  except end;
end;
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: IPXC_Bookmark

Post by Sasha - Tracker Dev Team »

Hello Jeff,

Please read the Bookmarks part (12.3.3 Document Outline) and the Actions part (12.6 Actions) in the PDF specification for better understanding. Also, try creating bookmarks in the End-User Editor and look into the Actions list for the clarification.
As you are using the Editor SDK then it's better to modify the action list with the operation:
https://sdkhelp.pdf-xchange.com/vie ... s_setProps
The action list should be created using the:
https://sdkhelp.pdf-xchange.com/vie ... ctionsList
The AddGoTo method should be used to add the appropriate GoTo Action:
https://sdkhelp.pdf-xchange.com/vie ... st_AddGoto

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Bookmark

Post by jeffp »

This seems to do it in case anyone else is asking.

Code: Select all

procedure TMyPDF.AddBookmark(APage: Integer; ATitle: String; APrepend: Boolean = False);
var
  BM: IPXC_Bookmark;
  AL: IPXC_ActionsList;
  A: IPXC_Action;
  D: PXC_Destination;
begin
  if Assigned(FDoc) then
  try
    D.nPageNum := APage - 1;
    D.nType := Dest_XYZ;
    AL := FDoc.CreateActionsList;
    AL.AddGoto(D, A);
    FDoc.BookmarkRoot.AddNewChild(not APrepend, BM);
    BM.Set_Title(ATitle);
    BM.Set_Actions(AL);
  except end;
end;
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: IPXC_Bookmark

Post by Sasha - Tracker Dev Team »

Hello Jeff,

Yes, that's exactly what needs to be done. Though this will inherit all of the x, y and zoom from the current view when switching to the page .

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Bookmark

Post by jeffp »

What's your suggestion for

D.nType := Dest_XYZ; ?

What is the best setting here?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: IPXC_Bookmark

Post by Sasha - Tracker Dev Team »

Hello Jeff,

Well the default recommended behavior would be to go to the top left corner of the page. Basically that will look like this:

Code: Select all

uint nPageNumber = 1;
PDFXEdit.PXC_Destination dest = new PDFXEdit.PXC_Destination();
PDFXEdit.PXC_Rect rc = pdfCtl.Doc.CoreDoc.Pages[nPageNumber].get_Box(PDFXEdit.PXC_BoxType.PBox_PageBox);
dest.nType = PDFXEdit.PXC_DestType.Dest_XYZ;
dest.dValues = new Double[4];
dest.dValues[0] = rc.left;
dest.dValues[1] = rc.top;
dest.nNullFlags = 12;
dest.nPageNum = nPageNumber;
pdfCtl.GoToDestination(ref dest);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ