We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Example of how to capture documentloaded event

Thread ID:





149377 Nov 24,2019 09:19 AM UTC Nov 28,2019 06:45 AM UTC Blazor 3
Tags: PDF Viewer
Dean Walker
Asked On November 24, 2019 09:19 AM UTC


I have a serverblazor project and I want to perform a search on a ejspdfviewerserver control after the DocumentPath property is changed.

I've declared the viewer as such in my razor page

<EjsPdfViewerServer @ref="@PDFViewer" DocumentPath="@strFileArchivePath" ToolbarSettings="@ToolbarSettings" />

So, changing the value of my variable strFileArchivePath works as expected and loads the pdf file.

BUT if i then try to call the getsearchtext method after changing the variable

PDFViewer.GetTextSearch().SearchText(strSearchTerm, false);

It doesn't work, i suspect this is due to code not awaiting the load of the file and therefore it searching before the file has finished loading.

I don't want to use the load method and then the search method, i'd like to subscribe to the "DocumentLoaded" event of the viewer but i cant work out how to do this, can someone provide a simple example please?

Many thanks,


Mohan Selvaraj [Syncfusion]
Replied On November 25, 2019 01:01 PM UTC

Hi Dean, 

Thanks for using Syncfusion Products. 

The Event in the Blazor PDF Viewer control has to be wrapped inside the <PdfViewerEvents>  tag . Please find the below code-snippet for adding the DocumentLoaded event in PDF Viewer Balzor control. 

<EjsPdfViewerServer @ref="@PDFViewer" Height="500px" Width="1060px" DocumentPath="@documentPath"> 
    <PdfViewerEvents DocumentLoaded="@DocumentLoaded"></PdfViewerEvents> // The events has to be provided like this. 

    EjsPdfViewerServer PDFViewer; 
    private string documentPath { get; set; } = "wwwroot/Data/FormFillingDocument.pdf"; 

    private void DocumentLoaded(LoadEventArgs args) 
        PDFViewer.GetTextSearch().SearchText("Name", false); 

We have created the simple PDF Viewer Blazor sample for the same with searching the text on DocumentLoaded event. Kindly download from the below link. 

Mohan S 

Dean Walker
Replied On November 26, 2019 10:06 AM UTC


Many thanks for your quick reply and example!

I've tried the code and it works exactly as I need.



Padmini Ramamurthy [Syncfusion]
Replied On November 28, 2019 06:45 AM UTC

Hi Dean, 
Glad that the provided solution works and please get back to us if you need any other assistance. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon