Highlight underline strikeout text in EJ2 TypeScript Pdfviewer control

8 May 20231 minute to read

The PDF Viewer library allows you to highlight, underline and strikeout text in the loaded PDF document programmatically using the setAnnotationMode() method.

Step 1: Follow the steps provided in the link to create simple PDF Viewer sample.

Step 2: Add the following code snippet to highlight, underline, and strikeout text in index.ts file with button click events.

    document.getElementById('setHighlight').addEventListener('click', ()=> {
    viewer.annotation.setAnnotationMode('Highlight');
    });
    document.getElementById('setUnderline').addEventListener('click', ()=> {
    viewer.annotation.setAnnotationMode('Underline');
    });
    document.getElementById('setStrikeout').addEventListener('click', ()=> {
    viewer.annotation.setAnnotationMode('Strikethrough');
    });
    document.getElementById('setNone').addEventListener('click', ()=> {
    viewer.annotation.setAnnotationMode('None');
    });

Find the Sample how to highlight, underline and strikeout text programmatically