Annotation toolbar customization
The annotation toolbar can be customized by showing or hiding default items and by controlling the order in which the items appear.
Show or hide the annotation toolbar
Show or hide the annotation toolbar programmatically during initialization or at runtime.
Use the EnableAnnotationToolbar property or the ShowAnnotationToolbar method to toggle visibility.
The following code snippet explains how to show or hide the annotation toolbar using the ShowAnnotationToolbar method.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 @ref="viewer" Height="100%" Width="100%" DocumentPath="@documentPath">
<PdfViewerEvents DocumentLoaded="DocumentLoad"></PdfViewerEvents>
</SfPdfViewer2>
@code {
private string documentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
SfPdfViewer2 viewer;
//Invokes while loading document in the PDFViewer.
public void DocumentLoad(LoadEventArgs args)
{
//Shows the annotation toolbar on initial loading.
viewer.ShowAnnotationToolbar(true);
//Code to hide the annoatation toolbar.
//viewer.ShowAnnotationToolbar(false);
}
}How to customize the annotation toolbar
Choose which tools appear and control their order in the annotation toolbar.
Use PdfViewerToolbarSettings with the AnnotationToolbarItems property to choose which tools are displayed in the annotation toolbar. The property accepts a list of AnnotationToolbarItem values. Only the items included in this list are shown; any item not listed is hidden. The rendered order follows the sequence of items in the list.
The annotation toolbar is presented when entering annotation mode in SfPdfViewer2 and adapts responsively based on the available width. Include the Close tool to allow users to exit the annotation toolbar when needed.
The following example demonstrates how to customize the annotation toolbar by specifying a selected set of tools using AnnotationToolbarItem.
<!-- Container for the PDF Viewer -->
<div class="Pdf-viewer-container">
<!-- SfPdfViewer2 component with annotation toolbar enabled -->
<SfPdfViewer2 @ref="PdfViewerInstance" EnableFormDesigner="true"
DocumentPath="wwwroot/data/Form_Designer.pdf"
Height="650px"
Width="100%">
<!-- Configuring the annotation toolbar items -->
<PdfViewerToolbarSettings AnnotationToolbarItems="AnnotationToolbarItems"></PdfViewerToolbarSettings>
</SfPdfViewer2>
</div>
@code {
// Reference to the SfPdfViewer2 instance
SfPdfViewer2 PdfViewerInstance { get; set; }
// Define a list of annotation toolbar items to be displayed and usable
List<AnnotationToolbarItem> AnnotationToolbarItems { get; set; } = new List<AnnotationToolbarItem>()
{
AnnotationToolbarItem.UnderlineTool,
AnnotationToolbarItem.StampAnnotationTool,
AnnotationToolbarItem.FreeTextAnnotationTool,
AnnotationToolbarItem.FontSizeAnnotationTool,
AnnotationToolbarItem.CloseTool
};
}Refer to the image below for the desktop view (items shown in the order configured).

Refer to the image below for the mobile view (responsive layout adapts to width).
