Search results

Highlight, Underline and Strikeout text programmatically

08 Dec 2021 / 1 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.

Copied to clipboard
    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