Skip to content
ComPDF
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

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];