Windows
ComPDFKit PDF SDK
Guides

Create, Move, or Delete Text and Images                    

 

ComPDFKit provides methods to do various operations like creating text/images.

 

You can use the mouse and keyboard to manipulate text or image areas on CPDFViewer as in Microsoft Word, if you want to copy, paste, cut, or delete text or images, you can use the CPDFViewer's PDFEditCommandHandler event. The following code will show you how to do this.

 

viewer.PDFEditCommandHandler += Viewer_PDFEditCommandHandler;
private void Viewer_PDFEditCommandHandler(object sender, TextEditCommand e)
{
    e.Handle = true;
    e.PopupMenu = new ContextMenu();
    e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
    e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
    e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
    e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
    e.PopupMenu.Items.Add(new MenuItem() { Header = "Select All", Command = ApplicationCommands.SelectAll, CommandTarget = (UIElement)sender });
}

 

You can use CPDFViewer's SetPDFEditCreateType method to insert the text and image. The following code will show you how to do this.

 

//Insert text.
viewer.SetPDFEditCreateType(CPDFEditType.EditText);

//Insert image.
viewer.SetPDFEditCreateType(CPDFEditType.EditImage);