PDF Editing
PDF editing provides the ability to change content so that its data can be improved or re-purposed.
- Edit text.
- Remove specific content from existing pages.
- Insert or append new content to existing pages.
Enter or End the Editing Mode
You can use beginEdit()
of CPDFEditManager
to enter the editing mode. After entering, the text blocks surrounded by dotted lines will be displayed in the PDF document, then you can copy, paste, cut, or delete text. And other operations are not supported at this time, like adding/deleting annotations, adding watermarks, modifying form properties, etc. In addition, you can also listen to the current text-editing status of the PDF document by adding a listener.
When finishing editing text, you can use exitEdit
of CPDFEditManager
to exit the editing mode. After exiting, the display and operations will be the same as before entering the editing mode.
You can enter or exit the editing mode at any time. When you need to save the changes of editing text, you should use endEdit
of CPDFEditManager
to end the editing mode. Otherwise, it will be different from the expected result when you use saveAs
or save
of CPDFDocument
to save the changes to the disk.
The following code will show you how to implement these operations.
//Get the class about managing PDF editing.
CPDFEditManager editManager =
readerView.getEditManager();
//Enter text-editing mode.
editManager.beginEdit(CPDFEditManager.LoadText);
//Add the listener to listen the changes of text-editing status.
editManager.addEditStatusChangeListener(new OnEditStatusChangeListener() {
@Override
public void onBegin(int type) {
//Do something.
}
@Override
public void onExit() {
//Do something.
}
});
//Exit the editing mode.
editManager.exitEdit();
//End the editing mode.
editManager.endEdit();