Articles in this section
Category / Section

How to display PDFs from byte arrays using Blazor PDF Viewer

3 mins read

The Blazor PDF Viewer is a UI component for displaying PDFs from byte arrays, streams, or file paths. In addition to being able to print PDFs, it also supports reviewing PDFs with annotation tools. Thumbnails, bookmarks, hyperlinks, and tables of content provide easy navigation within and outside PDF files. The form-filling support allows filling and printing with AcroForms.

 

Display PDF from byte arrays

In this knowledge base, you can find information about how to display PDF files from byte arrays. The following code sample explains how the PDF file can be loaded in the PDF Viewer as a base64 string.

Refer to the following code sample.

@using Syncfusion.Blazor.PdfViewerServer
 
<SfPdfViewerServer ID="pdfviewer" DocumentPath="@DocumentPath" Width="1060px" Height="500px"/>
 
@code {
    static byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/data/PDF_Succinctly.pdf");
    static string base64String = Convert.ToBase64String(byteArray);
    public string DocumentPath { get; set; } = "data:application/pdf;base64," + base64String;
}
 

 

You can refer to this link to learn about how to open PDF files from various locations. Also, please find the following information about opening PDFs from the following locations:

 

 

Conclusion

We hope you enjoyed learning about how to display PDFs from byte arrays using the Blazor PDF Viewer. You can explore the runnable sample of displaying PDFs from byte arrays using the Blazor PDF Viewer from this GitHub location.

You can refer to our Blazor PDF Viewer feature tour page to learn about its other groundbreaking features. You can also explore our Blazor PDF Viewer example to understand how to present and manipulate data.

For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to evaluate our Blazor PDF Viewer and other Blazor components.



If you have any questions or require clarifications, please let us know in the comments below. You can also contact us through our support forums.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied