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.

Get the Selected Content

Users can drag the mouse or use their fingers to select text in the PDF document, obtaining the selected content in real-time.

This example shows how to Get the selected content:

swift
// Extract the selected text
let currentSelection = pdfview.currentSelection
let currentText = currentSelection?.string()
objective-c
// Extract the selected text
CPDFSelection *currentSelection = pdfView.currentSelection;
NSString *currentText = [currentSelection string];