Import annotations as objects in Blazor SfPdfViewer Component
The Syncfusion® Blazor SfPdfViewer component supports importing annotations from an object that was previously exported by the component. To obtain such an annotation object, use the ExportAnnotationsAsObjectAsync() method. Only annotation objects exported by the SfPdfViewer component can be imported.
The following example shows how to export annotations as an object and import them back using the SfPdfViewer component.
@page "/"
@using Syncfusion.Blazor.SfPdfViewer
<button @onclick="ExportAnnot">ExportAnnot</button>
<button @onclick="ImportAnnot">ImportAnnot</button>
<SfPdfViewer2 @ref="PdfViewer"
DocumentPath="@DocumentPath"
Height="100%"
Width="100%">
</SfPdfViewer2>
@code {
public SfPdfViewer2 PdfViewer { get; set; }
private string DocumentPath { get; set; } = "PDF_Succinctly.pdf";
public object annotation;
//Export the annotations as an object
public async void ExportAnnot()
{
await PdfViewer.ExportAnnotation();
annotation = await PdfViewer.ExportAnnotationsAsObjectAsync();
}
//Import the annotations that are exported as objects
public async void ImportAnnot()
{
await PdfViewer.ImportAnnotation(annotation);
}
}
NOTE
Refer to the Blazor SfPdfViewer feature tour for an overview of key capabilities. Explore the Blazor SfPdfViewer example to see the core features in action.