Example of how to capture documentloaded event
Hi,
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,
Dean
SIGN IN To post a reply.
3 Replies
MS
Mohan Selvaraj
Syncfusion Team
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>
@code{
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.
Regards,
Mohan S
DW
Dean Walker
November 26, 2019 10:06 AM UTC
Hi,
Many thanks for your quick reply and example!
I've tried the code and it works exactly as I need.
Regards,
Dean
PR
Padmini Ramamurthy
Syncfusion Team
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.
Regards,
Padmini
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
DW Dean Walker
- Nov 24, 2019 09:19 AM UTC
- Nov 28, 2019 06:45 AM UTC