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

Can I add an option in Context menu in Adobe Acrobat page? Or how to handle events for ctrl +c/v

Explorer ,
May 28, 2025 May 28, 2025

I am working on a plugin which runs on Adobe Acrobat.
1. I need to copy a custom annotation ( Has image ) and should be able to paste in any page or any other opened pdf document page.  If I do ctrl +c and ctrl +v nothing happens. Checked the flags too it returns 4 which states "PrintAnnot" so the annot is not locked. Not sure if any thing more needs to be added in that annot. Because PDAnnotCanCopy returns false.

 

As of now, Manually creating the annotation by copying its appearance and rectangle. 


I have my code ready but how can I catch (Control + c and Control + v) events?


Code: 

 

AVAppRegisterForPageViewKeyDown(MyKeyDownHandler,NULL);
....
....


ASBool TTCPlugIn::MyKeyDownHandler(AVPageView pageView, AVKeyCode key, AVFlagBits16 modifiers, void* data)
{

if ((modifiers & AV_CONTROL) && ((key == 'C')||(key=='c')) )
{
// Handle Ctrl+C
AVAlertNote("Ctrl+C was pressed!");
return true; // Event handled
}
return false; 
}

 

This code works fine if I press C or c or any other alphabet. Doesnt gets triggered if I do a ctrl +c . 

Modifiers are 0 every time . 

 

 

2. Is it possible that I can add an option in context menu? 

 

AVAppRegisterForContextMenuAddition(ASAtomFromString("MY_MENU"), MyContextMenuAdditionProc, NULL);

 

 

 

 

void adddMe(void* S)
{
}

ACCB1 void ACCB2 MyContextMenuAdditionProc(ASAtom menuName, AVMenu menu, void* menuData, void* clientData) {
    // Check if it's the page view context menu
    if (ASAtomGetString(menuName) && strcmp(ASAtomGetString(menuName), "AVPageViewContextMenu") == 0) {
        AVMenuItem menuItem = AVMenuItemNew("My Custom Context Action",
            "NID_MY_CONTEXT_ACTION",
            NULL,
            false,
            0,
            0,
            NULL,
            gExtensionID);

        AVMenuItemSetExecuteProc(menuItem,
            ASCallbackCreateProto(AVExecuteProc, adddMe),
            NULL);

        AVMenuAddMenuItem(menu, menuItem, APPEND_MENUITEM);
    }
}

 

 

177
Translate
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 ,
May 28, 2025 May 28, 2025

[Moved to the Acrobat SDK forum]

Translate
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 ,
May 28, 2025 May 28, 2025

I have had many wierd issues trying to capture keystrokes in Acrobat. I believe this is because Acrobat grabs them first and decides what to pass along.  Keys with special meaning don't normally get passed on.  Being a loaded DLL means you are low man on the messaging totem pole. 

To solve this issue, and many other event related issues (such as mouse actions)  subclass the document window.  This still doesn't pass on everything, but it does get you the control key.  

 

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

Translate
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 ,
May 28, 2025 May 28, 2025
LATEST

The menu type parameter in AVAppRegisterForContextMenuAddition must be "page".

AVAppRegisterForContextMenuAddition(ASAtomFromString("page"),...)

 

 

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

Translate
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