NOTE

Syncfusion recommends using Blazor PDF Viewer (NextGen) Component which provides fast rendering of pages and improved performance. Also, there is no need of external Web service for processing the files and ease out the deployment complexity. It can be used in Blazor Server, WASM and MAUI applications without any changes.

Free text annotations in Blazor PDF Viewer Component

8 Aug 20243 minutes to read

The PDF Viewer control provides the options to add, edit and delete the free text annotations.

Adding a free text annotation to the PDF document

The free text annotations can be added to the PDF document using the annotation toolbar.

  • Click the Edit Annotation button in the PDF Viewer toolbar. A toolbar appears below it.
  • Select the Free Text Annotation button in the annotation toolbar. It enables the Free Text Annotation mode.
  • You can add the text over the pages of the PDF document.

In the pan mode, if the free text annotation mode is entered, the PDF Viewer control will switch to text select mode.

Free Text Annotation in Blazor PDFViewer

@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.PdfViewer

<SfButton OnClick="OnClick">Click Here</SfButton>
<SfPdfViewerServer DocumentPath="@DocumentPath" @ref="viewer" Width="1060px" Height="500px">
</SfPdfViewerServer>

@code{
    SfPdfViewerServer viewer;

    public void OnClick(MouseEventArgs args)
    {
        viewer.SetAnnotationMode(AnnotationType.FreeText);
    }
    private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
}

Editing the properties of free text annotation

The font family, font size, font styles, font color, text alignment, fill color, the border stroke color, border thickness, and opacity of the free text annotation can be edited using the Font Family tool, Font Size tool, Font Color tool, Text Align tool, Font Style tool Edit Color tool, Edit Stroke Color tool, Edit Thickness tool, and Edit Opacity tool in the annotation toolbar.

Editing font family

The font family of the annotation can be edited by selecting the desired font in the Font Family tool.

Editing Font Family of Blazor PDFViewer Text

Editing font size

The font size of the annotation can be edited by selecting the desired size in the Font Size tool.

Editing Font Size of Blazor PDFViewer Text

Editing font color

The font color of the annotation can be edited using the color palette provided in the Font Color tool.

Editing Font Color of Blazor PDFViewer Text

Editing the text alignment

The text in the annotation can be aligned by selecting the desired styles in the dropdown pop-up in the Text Align tool.

Editing Free Text Annotation in Blazor PDFViewer

Editing text styles

The style of the text in the annotation can be edited by selecting the desired styles in the dropdown pop-up in the Font Style tool.

Editing Font Style in Blazor PDFViewer

Editing fill color

The fill color of the annotation can be edited using the color palette provided in the Edit Color tool.

Editing Fill Color in Blazor PDFViewer Text

Editing stroke color

The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool.

Editing Stroke Color of Blazor PDFViewer Text

Editing thickness

The thickness of the border of the annotation can be edited using the range slider provided in the Edit Thickness tool.

Editing Font Border Thickness of Blazor PDFViewer Text

Editing opacity

The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool.

Editing Font Opacity in Blazor PDFViewer

Setting default properties during control initialization

The properties of the free text annotation can be set before creating the control using FreeTextSettings.

After editing the default values, they will be changed to the selected values.

@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.PdfViewer

<SfPdfViewerServer @ref="@viewer" DocumentPath="@DocumentPath" FreeTextSettings="@FreeTextSettings">
</SfPdfViewerServer>
@code{
        SfPdfViewerServer viewer;
        private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
        PdfViewerFreeTextSettings FreeTextSettings = new PdfViewerFreeTextSettings{FillColor="green",BorderColor="blue",FontColor="yellow"};

}

NOTE

You can refer to the Blazor PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore the Blazor PDF Viewer example to understand how to explain core features of PDF Viewer.