I am running the code below to attempt to remove a page I created and added a legend to. It gets no error. I created a test file that only had one page and a legend. If I step in the debugger, I see the scroll bar change as if there is no second page and then change back. the second page is now a blank page and does not have the legend content. The bookmark is gone. If I attempt to delete the pag in the UI, I get an error indicating the page is in use. If I save and close thfile, then reopen it, I still get an error saying the page is in use if I try to delete it in the UI.
void RemoveLegendBookmark(PDDoc pdDoc)
{
DURING
// We make top-level bookmarks only, so add a new bookmark to the root
PDBookmark bmRoot, bmNode;
bmRoot = PDDocGetBookmarkRoot(pdDoc);
if (PDBookmarkHasChildren(bmRoot))
{
bmNode = PDBookmarkGetByTitle(bmRoot, pOptions->LegendBookmarkTitle.c_str(), pOptions->LegendBookmarkTitle.length(), -1);
if(PDBookmarkIsValid(bmNode))
{
// get the action for the current bookmark
PDAction bookmarkAction = PDBookmarkGetAction(bmNode);
// get the view destination for the current bookmark's action
PDViewDestination bookmarkViewDestination = PDActionGetDest(bookmarkAction);
bookmarkViewDestination = PDViewDestResolve(bookmarkViewDestination, pdDoc);
ASInt32 pageNum;
ASAtom fitType;
ASFixedRect destRect;
ASFixed zoom;
PDViewDestGetAttr(bookmarkViewDestination, &pageNum, &fitType, &destRect, &zoom);
PDViewDestDestroy(bookmarkViewDestination);
PDBookmarkDestroy(bmNode);
PDDocDeletePages(pdDoc, pageNum, pageNum, NULL, NULL);
}}
HANDLER
// exception handling
char errorMsg[256];
ASGetErrorString(ASGetExceptionErrorCode(), errorMsg, 256);
void LogError(string errorMsg);
END_HANDLER
}