View the created PDF document

8 Sep 20222 minutes to read

The Syncfusion’s Blazor PDF Viewer component allows you to view the created PDF document using the Created event.

The following code example shows how to view the created PDF document.

<SfPdfViewerServer ID="pdfviewer" @ref="@PdfViewer" DocumentPath="@documentPath">
    <PdfViewerEvents Created="created"></PdfViewerEvents>


    public SfPdfViewerServer PdfViewer { get; set; }
    public string documentPath { get; set; }
    private void created()
        var document = new PdfDocument();
        byte[] bytes;
        //Add a new page to the PDF document.
        PdfPage page = document.Pages.Add();
        //Create a textbox field and add the properties.
        PdfTextBoxField textBoxField = new PdfTextBoxField(page, "FirstName");
        textBoxField.Bounds = new RectangleF(0, 0, 100, 20);
        textBoxField.ToolTip = "First Name";
        //Add the form field to the document.
        var stream = new MemoryStream();
        //Save the document.
        bytes = stream.ToArray();
        string base64string = Convert.ToBase64String(bytes);
        documentPath = "data:application/pdf;base64," + base64string;
        //close the document

Find the sample How to view the created PDF document