Text selection in ASP.NET Core PDF Viewer control
The TextSelection module enables users to select and copy text from the loaded PDF document. Text selection is enabled by default and can be configured, controlled programmatically, and monitored through events.
Enable or disable text selection
Use the enableTextSelection property to enable or disable selecting text in the PDF Viewer.
<div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                enableTextSelection="false">
    </ejs-pdfviewer>
</div><div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                serviceUrl="/api/PdfViewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                enableTextSelection="false">
    </ejs-pdfviewer>
</div>Text selection events
Monitor user interaction with text using events.
textSelectionStart
The textSelectionStart event triggers when selection is initiated. Typical use cases include disabling conflicting UI, logging, or customizing selection behavior.
<div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                textSelectionStart="textSelectionStarted">
    </ejs-pdfviewer>
</div>
<script>
    function textSelectionStarted(args) {
        // args.pageNumber, args.bounds provide the starting context
        console.log('Selection started', args);
    }
</script><div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                serviceUrl="/api/PdfViewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                textSelectionStart="textSelectionStarted">
    </ejs-pdfviewer>
</div>
<script>
    function textSelectionStarted(args) {
        // args.pageNumber, args.bounds provide the starting context
        console.log('Selection started', args);
    }
</script>textSelectionEnd
The textSelectionEnd event triggers when selection is completed. It is useful to read the selected content, enable context actions, or persist analytics.
<div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                textSelectionEnd="textSelectionEnded">
    </ejs-pdfviewer>
</div>
<script>
    function textSelectionEnded(args) {
        // For example, automatically copy or show a custom menu
        console.log('Selection ended', args);
    }
</script><div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                serviceUrl="/api/PdfViewer"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                textSelectionEnd="textSelectionEnded">
    </ejs-pdfviewer>
</div>
<script>
    function textSelectionEnded(args) {
        // For example, automatically copy or show a custom menu
        console.log('Selection ended', args);
    }
</script>