Guides
Context Menu
When an annotation, text, form, or content editor object is selected, a context menu pops up to support object operations. ContextMenuConfig controls the menu style and the menu item list for each scenario.
Global Style
json
{
"contextMenuConfig": {
"backgroundColor": "",
"fontSize": 14,
"padding": [0, 0, 0, 0],
"iconSize": 36
}
}1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
| Field | Description |
|---|---|
backgroundColor | Menu background color (empty string uses default) |
fontSize | Menu text size |
padding | Menu padding [left, top, right, bottom] |
iconSize | Icon size |
Global Menu
The global configuration applies to global context menus across all modes:
json
{
"contextMenuConfig": {
"global": {
"screenshot": [
{ "key": "exit" },
{ "key": "share" }
]
}
}
}1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Viewer Mode Menu
viewMode configures menus in viewer mode:
json
{
"contextMenuConfig": {
"viewMode": {
"textSelect": [
{ "key": "copy" }
]
}
}
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Annotation Mode Menu
annotationMode contains the following sub-menu scenarios:
Text Selection
json
"textSelect": [
{ "key": "copy" },
{ "key": "highlight" },
{ "key": "underline" },
{ "key": "strikeout" },
{ "key": "squiggly" }
]1
2
3
4
5
6
7
2
3
4
5
6
7
Long Press on Blank Area
json
"longPressContent": [
{ "key": "paste" },
{ "key": "note" },
{ "key": "textBox" },
{ "key": "stamp" },
{ "key": "image" }
]1
2
3
4
5
6
7
2
3
4
5
6
7
Markup Annotations (Highlight/Underline/Strikeout/Squiggly)
json
"markupContent": [
{ "key": "properties" },
{ "key": "note" },
{ "key": "reply" },
{ "key": "viewReply" },
{ "key": "delete" }
]1
2
3
4
5
6
7
2
3
4
5
6
7
Other Annotation Types
| Scenario | Config Key | Supported Menu Items |
|---|---|---|
| Ink | inkContent | properties, note, reply, viewReply, delete |
| Shape | shapeContent | properties, note, reply, viewReply, delete |
| FreeText | freeTextContent | properties, edit, reply, viewReply, delete |
| Sound | soundContent | reply, viewReply, play, record, delete |
| Stamp | stampContent | note, reply, viewReply, delete, rotate |
| Signature Stamp | signStampContent | signHere, delete, rotate |
| Link | linkContent | edit, delete |
Content Editor Mode Menu
contentEditorMode contains the following scenarios:
Text Area
json
"editTextAreaContent": [
{ "key": "properties" },
{ "key": "edit" },
{ "key": "cut" },
{ "key": "copy" },
{ "key": "delete" }
]1
2
3
4
5
6
7
2
3
4
5
6
7
Selected Text
json
"editSelectTextContent": [
{ "key": "properties" },
{ "key": "opacity", "subItems": ["25%", "50%", "75%", "100%"] },
{ "key": "cut" },
{ "key": "copy" },
{ "key": "delete" }
]1
2
3
4
5
6
7
2
3
4
5
6
7
Text Input
json
"editTextContent": [
{ "key": "select" },
{ "key": "selectAll" },
{ "key": "paste" }
]1
2
3
4
5
2
3
4
5
Image Area
json
"imageAreaContent": [
{ "key": "properties" },
{ "key": "rotateLeft" },
{ "key": "rotateRight" },
{ "key": "replace" },
{ "key": "export" },
{ "key": "opacity", "subItems": ["25%", "50%", "75%", "100%"] },
{ "key": "flipHorizontal" },
{ "key": "flipVertical" },
{ "key": "crop" },
{ "key": "delete" },
{ "key": "copy" },
{ "key": "cut" }
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Path Area
json
"editPathContent": [
{ "key": "delete" }
]1
2
3
2
3
Long Press on Blank Area
json
"longPressWithEditTextMode": [
{ "key": "addText" },
{ "key": "paste" },
{ "key": "keepSourceFormatingPaste" }
]1
2
3
4
5
2
3
4
5
json
"longPressWithEditImageMode": [
{ "key": "addImages" },
{ "key": "paste" }
]1
2
3
4
2
3
4
Search & Replace
json
"searchReplace": [
{ "key": "replace" }
]1
2
3
2
3
Form Mode Menu
formMode configures menus for each form type:
json
{
"contextMenuConfig": {
"formMode": {
"textField": [{ "key": "properties" }, { "key": "delete" }],
"checkBox": [{ "key": "properties" }, { "key": "delete" }],
"radioButton": [{ "key": "properties" }, { "key": "delete" }],
"listBox": [{ "key": "options" }, { "key": "properties" }, { "key": "delete" }],
"comboBox": [{ "key": "options" }, { "key": "properties" }, { "key": "delete" }],
"signatureField": [{ "key": "startToSign" }, { "key": "delete" }],
"pushButton": [{ "key": "options" }, { "key": "properties" }, { "key": "delete" }]
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Adding Custom Menu Items
Add custom buttons to any menu scenario:
1. JSON Configuration
json
{
"contextMenuConfig": {
"annotationMode": {
"markupContent": [
{ "key": "properties" },
{ "key": "note" },
{
"key": "custom",
"identifier": "custom_markup_action_get_text",
"title": "Get Text",
"icon": "ic_test_get_text",
"showType": "text"
},
{ "key": "delete" }
]
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| Field | Description |
|---|---|
key | Must be "custom" for custom buttons |
identifier | Unique identifier to distinguish different buttons in callbacks |
title | Display text |
icon | Icon resource name (must be in res/drawable) |
showType | Display type: "text" or "icon" |
2. Adding Callbacks
java
CPDFCustomEventCallbackHelper.getInstance().addCustomEventCallback(extraMap -> {
String customEventType = extraMap.get(
CPDFCustomEventField.CUSTOM_EVENT_TYPE).toString();
if (CPDFCustomEventType.CONTEXT_MENU_ITEM_TAPPED.equals(customEventType)) {
String identifier = extraMap.get(CPDFCustomEventField.IDENTIFIER).toString();
switch (identifier) {
case "custom_markup_action_get_text":
CPDFAnnotation annotation = (CPDFAnnotation) extraMap.get(
CPDFCustomEventField.ANNOTATION);
if (annotation instanceof CPDFMarkupAnnotation) {
String text = ((CPDFMarkupAnnotation) annotation).getMarkedText();
CToastUtil.showToast(getApplicationContext(), text);
}
break;
}
}
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
kotlin
CPDFCustomEventCallbackHelper.getInstance().addCustomEventCallback { extraMap ->
val customEventType = extraMap[CPDFCustomEventField.CUSTOM_EVENT_TYPE].toString()
if (CPDFCustomEventType.CONTEXT_MENU_ITEM_TAPPED == customEventType) {
val identifier = extraMap[CPDFCustomEventField.IDENTIFIER].toString()
when (identifier) {
"custom_markup_action_get_text" -> {
val annotation = extraMap[CPDFCustomEventField.ANNOTATION]
if (annotation is CPDFMarkupAnnotation) {
CToastUtil.showToast(applicationContext, annotation.markedText)
}
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Preview
