How to load PDF from URL to server-side PDF viewer.

30 Aug 20231 minute to read

We already support loading PDF documents from remote URLs. However, you can also load a document from a URL on the server side using the code provided below.

@using Syncfusion.Blazor.SfPdfViewer

<SfPdfViewer2 DocumentPath="@DocumentPath"

@code {
    public string DocumentPath { get; set; }
    protected override void OnInitialized()
        string Url = "";
        System.Net.WebClient webClient = new System.Net.WebClient();
        byte[] byteArray = webClient.DownloadData(Url);
        DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(byteArray);

View sample in GitHub