Skip to content
ComPDF
Guides

Delete Text and Images

The ComPDF React Native SDK provides convenient APIs for deleting text and image content.

This method is used to remove edit areas (text areas, image areas, or path areas) from the document. It is typically used in combination with edit selection events, allowing users to select and delete specific content.

Parameters:

  • editArea: The edit area object to delete. It can be one of the following types:
    • CPDFEditTextArea: Text edit area
    • CPDFEditImageArea: Image edit area
    • CPDFEditPathArea: Path edit area

Example:

tsx
// Listen for edit selection events and delete the selected edit area
pdfReaderRef.current?.addEventListener(
  CPDFEvent.EDITOR_SELECTION_SELECTED,
  (editArea) => {
    // console.log(JSON.stringify(editArea, null, 2));
    console.log("Selected Edit Area:");
    console.log(JSON.stringify(editArea, null, 2));
    setSelectEditArea(editArea);
  }
);

// Directly delete a specified edit area
pdfReaderRef.current?._document.removeEditArea(editArea);