How to display PDFs from byte arrays using Blazor PDF Viewer?
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:
- Opening a PDF from a URL
- Opening a PDF from the cloud
- Opening a PDF from the database
- Opening a PDF from the file system
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 Blazor PDF Viewer feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor PDF Viewer example to understand how to create 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 queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!