Custom PDF viewer

0
0

I’m using a customized pdfJs versione and I made a control:

public class PDF : Wisej.Web.PdfViewer
{
public PDF()
{
InitializeComponent();
this.ViewerType = PdfViewerType.Custom;
this.ViewerURL = @”Javascript\pdfJS\web\viewer.html”;
}

 

in the initScript I’ve setup a window listener

window.addEventListener(“message”, function(event) {
this.fireWidgetEvent(“loaded”, {data: event.data});
});

How can I fire an event on my PDF Class, with Widget I could use fireWidgetEvent.

 

  • You must to post comments
0
0

Use

    me.fireDataEvent("myevent", {data});

On the server in your C# class override:

  protected override void OnWebRender(dynamic config)
  {
    base.OnWebRender((object)config);
     config.wiredEvents.Add("myevent1", "myevent2", ...);
  }

  protected override void OnWebEvent(Core.WisejEventArgs e)
  {
    switch (e.Type)
    {
       case "myevent1":
         // do something
         break;
       case "myevent2":
         // do something
         break;
       default:
         base.OnWebEvent(e);
         break;
  }
 }

 

  • You must to post comments
0
0

Standard javascript events don’t keep the context, so “this” in the listener is just a reference to the brower’s window. A common technique when using plain javascript is to save the context in me or self:

var me = this;
window.addEventListener(“message”, function(event) {
   me.fireWidgetEvent(“loaded”, {data: event.data});
});

 

  • Davide Mercanti
    Ok. but the problem is that TypeError: me.fireWidgetEvent is not a function because I’m extending a PdfViewer , not a widget,
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.