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.

Find and Replace in Content Editing Mode

In content editing mode, when users perform text searches and replacements in a PDF document, the search results are typically highlighted, providing links for navigation to the corresponding positions. Users can also replace individual keywords or all occurrences of a keyword with the provided text. By leveraging the search and replace features provided by the ComPDF SDK, you can easily implement these functionalities.

Text Search

In content editing mode, text search allows users to input keywords to search for matching text throughout the entire PDF document. It also enables text replacement for individual or all occurrences of keywords.

swift
let results = document?.startFindEditText(from: page, with: "searchText", options:.caseSensitive)
objective-c
NSArray *results = [documet startFindEditTextFromPage:page withString:@"searchText" options:CPDFSearchCaseSensitive];

Single Replacement

Replace the text for a single keyword.

swift
let currentSelection: CPDFSelection
document?.replace(with: currentSelection, search: "searchText", toReplace: "replaceText")
objective-c
CPDFSelection *currentSelection;
  [documet replaceWithSelection:currentSelection searchString:@"searchText"  toReplaceString:@"replaceText" completionHandler:nil];

Replace All

Replace the text for all occurrences of a keyword.

swift
document?.replaceAllEditText(with:"searchText", toReplace: "replaceText")
objective-c
[documet replaceAllEditTextWithString:@"searchText" toReplaceString:@"replaceText"];