Back to Devexpress

DxPdfViewer.DocumentContent Property

blazor-devexpress-dot-blazor-dot-pdfviewer-dot-dxpdfviewer.md

latest1.6 KB
Original Source

DxPdfViewer.DocumentContent Property

Specifies a document’s content in binary data format.

Namespace : DevExpress.Blazor.PdfViewer

Assembly : DevExpress.Blazor.PdfViewer.v25.2.dll

NuGet Package : DevExpress.Blazor.PdfViewer

Declaration

csharp
[Parameter]
public byte[] DocumentContent { get; set; }

Property Value

TypeDescription
Byte[]

Document content as an array of bytes.

|

Remarks

Assign the binary content of a PDF document to the DocumentContent property to open the document in the PDF Viewer:

razor
@using System.Reflection

<DxPdfViewer @ref="pdfViewer"
             DocumentContent="@DocumentContent" />

@code {
    DxPdfViewer pdfViewer { get; set; }
    byte[] DocumentContent { get; set; }

    protected override async Task OnInitializedAsync() {
        Assembly assembly = Assembly.GetExecutingAssembly();
        Stream stream = assembly.GetManifestResourceStream("Pdf.DataSources.Document.pdf");

        using (var binaryReader = new BinaryReader(stream)) {
            DocumentContent = binaryReader.ReadBytes((int)stream.Length);
        }
    }
}

Run Demo: PDF Viewer - Overview

See Also

DxPdfViewer Class

DxPdfViewer Members

DevExpress.Blazor.PdfViewer Namespace