How to Change Text Highlight Color in Blazor PDF Viewer

14 Aug 20261 minute to read

Use the Color property of PdfViewerHighlightSettings to set the default highlight color for text markup annotations. This property applies only to Highlight annotations; other text-markup types, such as Underline and Strikethrough, use their own settings.

The following example shows how to set the highlight color.

@using Syncfusion.Blazor.SfPdfViewer

<!--Render simple PDF Viewer with customized highlight options-->
<SfPdfViewer2 @ref="PDFViewer"
              DocumentPath="@DocumentPath">
    <PdfViewerHighlightSettings Color="@highlightColor">
    </PdfViewerHighlightSettings>
</SfPdfViewer2>

@code {
    // Reference to the PDF Viewer instance.
    private SfPdfViewer2 PDFViewer;

    // Sets the PDF document path for initial loading.
    private string DocumentPath { get; set; } = "Data/PDF_Succinctly.pdf";

    // Defines the color for text markup annotations like highlight.
    private string highlightColor = "Green";
}

Highlighted text in Blazor PDF Viewer

View the sample on GitHub

Supported properties

In addition to Color, PdfViewerHighlightSettings exposes additional properties such as Opacity, IsLocked, Author, Subject, and ModifiedDate. Refer to the PdfViewerHighlightSettings API reference for the full list.

The value assigned to Color also sets the default selection in the highlight tool’s color picker in the toolbar.
N> Highlight annotations rendered using the default color set by PdfViewerHighlightSettings.Color.

See also