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