The PDF Viewer control provides the support to import and export annotations using JSON object in the PDF document.
You can import annotations using JSON file or JSON object in code behind like the below code snippet
@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="@OnImportAnnotationsClick">Import Annotations</SfButton>
<SfPdfViewerServer @ref=Viewer Width="1060px" Height="500px" DocumentPath="@DocumentPath" />
@code{
SfPdfViewerServer Viewer;
public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf";
public void OnImportAnnotationsClick(MouseEventArgs args)
{
Viewer.ImportAnnotations("wwwroot/data/ImportedAnnotation.json"); //The json file has been placed inside the data folder.
}
}
The JSON file for importing the annotation should be placed in the desired location and the path has to be provided correctly.
The PDF Viewer control provides the support to export the annotations as JSON file and JSON object using annotation toolbar.
Export annotations will be in the disabled state when the loaded PDF document does not contain any annotations.
You can export annotations as JSON file in code behind like the following code snippet
@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="@OnExportAnnotationsClick">Export Annotations</SfButton>
<SfPdfViewerServer Width="1060px" Height="500px" DocumentPath="@DocumentPath" @ref="@Viewer" />
@code{
SfPdfViewerServer Viewer;
public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf";
public void OnExportAnnotationsClick(MouseEventArgs args)
{
Viewer.ExportAnnotations();
}
}