Skip to main content
Inspiring
August 31, 2023
Question

PDDocDeletePages causing blank page that is "in use" to appear

  • August 31, 2023
  • 1 reply
  • 283 views

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
}
This topic has been closed for replies.

1 reply

Inspiring
August 31, 2023

a follow up...
If I create the legen, then add a page after it, then remove the legend (with code above) the blank page is appended; it does not repleace thone I am deleting. I think the delete works, but for some reason is triggering something that appends a page.