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 and images in the PDF document, obtaining the selected content in real-time.

This example shows how to Get the selected content:

C#
// Extract the selected text.
TextSelectInfo textSelectInfo = viewerTool.GetTextSelectInfo();
textSelectInfo.PageSelectText.TryGetValue(pageIndex, out string text);

// Extract the selected image.
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
myCPDFPage.GetImgSelection().GetImgBitmap(imageIndex, tempPath);