Download in Blazor PDF Viewer Component
17 Dec 20221 minute to read
The PDF Viewer supports downloading the loaded PDF file from the toolbar by default. You can enable or disable the download option by setting the EnableDownload
API.
@using Syncfusion.Blazor.PdfViewerServer
<SfPdfViewerServer Width="1060px" Height="500px" DocumentPath="@DocumentPath" EnableDownload="true"/>
@code{
public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf";
}
@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="OnClick">Download</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 OnClick(MouseEventArgs args)
{
Viewer.Download();
}
}
Download Filename
The DownloadFileName
property of the PDF Viewer enables you to sets the name of the file to be downloaded.
The following code example shows how to set default filename to the downloaded file.
@using Syncfusion.Blazor.PdfViewerServer
@using Syncfusion.Blazor.PdfViewer
<SfPdfViewerServer DocumentPath="@documentPath" DownloadFileName="@downloadFileName" Height="800px" Width="1000px"></SfPdfViewerServer>
@code
{
//Sets the PDF document path for initial loading.
public string documentPath { get; set; } = "wwwroot/Data/PDF Succinctly.pdf";
//Sets the name of the file to be downloaded.
private string downloadFileName { get; set; } = "TOP-View_CutSheets.pdf";
}
NOTE
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.