Import annotations as objects in Blazor SfPdfViewer Component
7 Oct 20241 minute to read
The Syncfusion’s Blazor SfPdfViewer component allows to import annotations from objects or streams instead of loading it as a file. To import such annotation objects, the SfPdfViewer control must export the PDF annotations as objects using the ExportAnnotationsAsObjectAsync() method. Only the annotations objects that are exported from the SfPdfViewer can be imported.
The following code example shows how to import annotations as objects, that are exported using the ExportAnnotationsAsObjectAsync() method.
@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
You can refer to our Blazor SfPdfViewer feature tour page for its groundbreaking feature representations. You can also explore our Blazor SfPdfViewer example to understand how to explains core features of SfPdfViewer.