Check whether selected annotation is being edited

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

vzgherea
User
Posts: 23
Joined: Mon Sep 09, 2013 8:38 am

Check whether selected annotation is being edited

Post by vzgherea »

Have to remove selected annotation programmatically.
Find selected annotation as follows:

DoDocumentVerb(0, null, "GetSelectedAnnot", null, out dataOut);
var selectedAnnotations = (int[]) dataOut;
if (selectedAnnotations[0] >= 0)
viewer.DoVerb(null, "ExecuteCommand", 33136, out dataOut, (int) PXCVA_Flags.PXCVA_NoUI);

Everything works great in case annotation is just selected. In case an annotation which has text (Sticky note/Type writer/Text box) is being edited it is returned within selection as well but an error is thrown when attempting to delete it. Want to skip deletion of annotations being edited. How can this be achieved?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Check whether selected annotation is being edited

Post by Vasyl - PDF-XChange »

Hi vzgherea.

You can try to stop editing of annotation before deleting:

Code: Select all

DoDocumentVerb(0, null, "GetSelectedAnnot", null, out dataOut);
var selectedAnnotations = (int[]) dataOut;
if (selectedAnnotations[0] >= 0)
{
    DoDocumentVerb(0, null, "Flush", null, null); // it stops current text editing and applies changes from text editor, removes selection
    DoDocumentVerb(0, null, "SelectAnnot", dataOut, null); // it restores annot selection
    viewer.DoVerb(null, "ExecuteCommand", 33136, out dataOut, (int) PXCVA_Flags.PXCVA_NoUI); // delete selected annot
}
HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
vzgherea
User
Posts: 23
Joined: Mon Sep 09, 2013 8:38 am

Re: Check whether selected annotation is being edited

Post by vzgherea »

Thank you for quick response!

As I specified in my first post I don't want to delete annotation in case it is being edited. So I need to get the exactly status of annotation - selected or being edited. Is this achievable?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Check whether selected annotation is being edited

Post by Vasyl - PDF-XChange »

Hi, vzgherea.

Sorry, but there is no way to get the annotation for which the text editor is running (or check if selected annotation is being edited).

In the future we can add new feature like to 'GetSelectedAnnot':

Code: Select all

DoDocumentVerb(0, null, "GetTextEditingAnnot", null, out dataOut);
var editingAnnot = (int[]) dataOut; // [<PageIndex>][<AnnotIndexOnPage>]
Please wait for next build.

For now you may try to use next workaround:

Code: Select all

int g_bTextEditorStarted = 0;
pdfViewer.SetProperty("Notifications.TextEditor.Filter", "All");

//////////////////////

youreventhandler OnEvent(type, name, ..)
{
    if ((type == PXCVA_OnNamedNotify) AND (name == "Notifications.TextEditor"))
    {
         int evtType = 0;
         pdfViewer.GetProperty("Notifications.TextEditor.Type", out evtType);
         if (evtType == 1) // start
             g_bTextEditorStarted++;
         else if ((evtType == 2) AND (g_bTextEditorStarted > 0)) // stop
             g_bTextEditorStarted--;
    }
}

bool TextEditorIsStarted()
{
      return (g_bTextEditorStarted > 0);
}

//////////////////////

if (!TextEditorIsStarted())
{
    DoDocumentVerb(0, null, "GetSelectedAnnot", null, out dataOut);
    var selectedAnnotations = (int[]) dataOut;
    if (selectedAnnotations[0] >= 0)
        viewer.DoVerb(null, "ExecuteCommand", 33136, out dataOut, (int) PXCVA_Flags.PXCVA_NoUI); // delete selected annot
}
Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.