Android
ComPDFKit PDF SDK
Guides

Edit PDF                                 

 

PDF editing provides the ability to change content so that its data can be improved or re-purposed.

- Create, move, or delete text and images.

- Edit text and images properties.

- Undo or redo any change.

- Customize the menu of text editing.

 

When editing PDF, other operations are not supported like adding or deleting annotations, adding watermarks, modifying form properties, etc.

 

PDF editing supports the following editing modes:

- Text Mode. In text mode, the text blocks surrounded by dotted lines will be displayed in the PDF document, then you can copy, paste, add, or delete text.

- Image Mode. In image mode, the images surrounded by dotted lines will be displayed in the PDF document, then you can delete, crop, rotate, mirror, replace, save images, or set transparency.

- Text-Image Mode. In text-image mode, the text blocks and images surrounded by dotted lines will be displayed in the PDF document, then you can edit text and images.

 

Initialize the Editing Mode

 

Before start editing, you should initialize editing mode. ComPDFKit provides methods to initialize editing mode. The following code shows you how to initialize the editing mode:

 

  //Get the class about managing PDF editing.
  CPDFEditManager editManager = readerView.getEditManager();
	//Enable editing
	editManager.enable();
  //Enter text editing mode.
  editManager.beginEdit(CPDFEditManager.LoadText);
  //Enter image editing mode.
  //editManager.beginEdit(CPDFEditManager.LoadImage);
  //Enter text-image editing mode.
  //editManager.beginEdit(CPDFEditManager.LoadText | CPDFEditManager.LoadImage);

 

ComPDFKit offers the ability to customize the appearance in editing mode. You can modify the display effect according to your requirements, such as the cursor color, cursor width, border color of the text block, and more. The following code shows you how to customize the appearance in editing mode:

 

//Get the configuration items of editing.
CPDFEditConfig.Builder builder = editManager.getEditConfigBuilder();
//Set the required configuration items.
CPDFEditConfig config = builder.setCursorColor(Color.BLUE)
						.setCursorWidth(10f)
						.setDefalutBoardWidth(5f)
						.setDefalutBoardColor(Color.RED)
						.build();
//Update the configuration items.
editManager.updateEditConfig(config);

 

Note: updateEditConfig needs to be used before using beginEdit() to enter the editing mode, otherwise, the current update will not take effect.