Create, Move and Delete Text, Images and Path
ComPDFKit provides comprehensive methods for creating, moving, and deleting text, images and path.
Performing Actions Through CPDFViewer
.
CPDFViewer
provides basic interactive capabilities by default, allowing the user to create and delete text, images and path, drag and drop to move the position of images, text blocks and path, resize images, text blocks and path, etc. by using the mouse and keyboard.
Configure the Context Menu.
If you need to copy, paste, cut, or delete text, images and path, you can add these methods to the context menu through the MouseRightButtonDownHandler
event of CPDFToolManager
.
This example shows how to configure the context menu:
// Register custom menu event
toolManager.MouseRightButtonDownHandler += ToolManager_MouseRightButtonDownHandler;
private void ToolManager_MouseRightButtonDownHandler(object sender, MouseEventObject e)
{
// Create a context menu on CPDFViewerTool and add menu items (Copy, Cut, Paste, Delete).
ContextMenu contextMenu = new ContextMenu();
contextMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
CPDFViewerTool tool = sender as CPDFViewerTool;
tool.ContextMenu = contextMenu;
}
Inserting Text and Images
You can specify the ability to insert text and image blocks through the SetPDFEditCreateType
method of CPDFViewer
. The following code shows how to achieve this:
// Insert Image
myCPDFView.SetPDFEditCreateType(CPDFEditType.EditImage);
// Insert Text
myCPDFView.SetPDFEditCreateType(CPDFEditType.EditText);
// Cancel
myCPDFView.SetPDFEditCreateType(CPDFEditType.None);