• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

SDK C++ finding a specific bookmark I create

Explorer ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

I am adding a bookmark to a legend for some annotation marks used in the document. It works fine for interactive use. But i also need to ba able to find it programmatically, ideally by some other method than looking for text.

The addition is very simple:

 

PDBookmark bmRoot, bmNode;
bmRoot = PDDocGetBookmarkRoot(pdDoc);
bmNode = PDBookmarkAddNewChild(bmRoot, pOptions->LegendTickmarksHeader.c_str());

 

the string being something they can set in options, but it would be optimal if they could edit it. I don't see a way to add anything like a tag that wouldn't be visible but that I could use. 

TOPICS
Acrobat SDK and JavaScript

Views

307

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

To find a bookmark you need to step through them. The text is available from PDBookmarkGetTitle. This might be in PDFDocEncoding or BOM-prefixed UCS-2 Unicode. 

To step through bookmarks look at PDDocGetBookmarkRoot, PDBookmarkGetNext. Because bookmarks may be nested you need to recursively use PDBookmarkGetFirstChild and enumerate the children.

In theory you could add an extra key to the bookmark ("Outline") dictionary. PDBookmarkGetCosObj gives you the Cos object for adding/checking extra keys. You will need to read about the structure of bookmarks (outlines) in the PDF Reference. 

To allow editing of the extra info you'd need to create your own UI. You cannot add anything to the existing bookmark UI. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

I mean that users can edit the bookmark name or delete content that includes the bookmarked content, so searching by the title may not be dependable. In my case, I may just document it. If they change the name and the legend is later updated, it will create a new one instead of updating current. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

LATEST

So you want some extra piece of unique data attached to a bookmark, so you can search for it regardless of any external changes made by the user? 

There are a couple of options. 

1) All bookmark entries are indirect COS objects, so they have a unique object ID that can be used to uniquely identify the bookmark.  When the user edits a bookmark, the indirect object remains the same. The object would only be lost if the user deleted the bookmark.  Even resetting the destination and moving the bookmark to a different location in the bookmark tree will not change the object ID.  

2) Add your own key to the bookmark object.  Acrobat ignore entries it doesn't need to muck about with.   So again,  resetting the destination and moving the bookmark do not affect any custom entries in the bookmark object. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines