Skip to content
ComPDF
DemoSampleAPI ReferenceFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Guides

End Content Editing and Save

After completing edits, you can exit editing mode by using endEdit with CPDFReaderView to switch out of edit mode. To save the changes, utilize either save() or saveAs() save the modified document.

java
// Exit edit mode
CPDFEditManager editManager = readerView.getEditManager();
if(editManager.isEditMode()){
  editManager.endEdit();
}
// Exit edit mode and switch to VIEW mode.
readerView.setViewMode(CPDFReaderView.ViewMode.VIEW);
try {
  CPDFDocument document = readerView.getPDFDocument();
  if (document.hasChanges()){
    // Save changes to the local document.
    document.save();
  }
} catch (Exception e){

}
kotlin
// Exit edit mode
val editManager = readerView.editManager
if(editManager.isEditMode()){
  editManager.endEdit()
}
// Exit edit mode and switch to VIEW mode.
readerView.viewMode = CPDFReaderView.ViewMode.VIEW
try {
  val document = readerView.pdfDocument
  if (document.hasChanges()){
    // Save changes to the local document.
    document.save();
  }
} catch (e : Exception){
}