Export to image or pdf displaying blank

Comments

4 comments

  • Avatar
    Moti Granovsky

    Hi Adei,

    In most cases I've seen, this happens because the widget's rendering is asynchronous and doesn't block the browser's thread, so as a result when the PDF export happens (on the server, via a headless browser) the headless browser sees the page's state as fully loaded and snaps the PDF, while in fact some widgets are still being rendered. 

    To overcome this, please try the following:

    1. To the widget manifest JSON, in the "options" property, add the field:

    triggersDomready
    : true


    2. Within the widget's "render" function or it's directive (depending on how the widget is implemented) find the spot where you can definitively know it is done rendering, and there add:

    widget.trigger("domready");

    What this does is notify Sisense it should wait for any instance of this widget to fire a "domready" event before it considers the dashboard fully rendered. And if the event is triggered correctly (at the right time) it will ensure the PDF export snapshot happens only when this widget (and all others using this mechanism) have triggered said event.

    Please let me know if you were able to use this approach to solve the issue. Thanks!

    0
    Comment actions Permalink
  • Avatar
    Adei Mandaluniz

    Thanks for your response Moti,

    As you say the render function it's asynchronous. I tried your approach, the domready trigger was already in place so I just added the widget's triggersDomready option, but still the same issue.

    I'm using Sisense version L8.0.3.127

    Any other suggestions apart from rewriting the widget to make the render synchronous? That would be my very last option

    0
    Comment actions Permalink
  • Avatar
    Moti Granovsky

    Having looked at the widget's code, I see that the "domready" event is triggered at the end of the function that renders and adjusts the mapbox-gl component, but not when rendering is actually done - which is what i meant in my original response.

    I would try to subscribe to the mapbox "load" event: https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:load

    and in that event handler, trigger "domready" - being async is not a problem as long as you have the ability to invoke a callback once the widget really is done rendering. If "load" doesn't work perhaps another event or method of the mapbox API can be used to determine when the map is truly rendered and "domready" can be triggered.

    Please let me know whether you succeed in fixing this issue with the above method - if not, we'll look for other options.

    0
    Comment actions Permalink
  • Avatar
    Adei Mandaluniz

    Thanks Moti!

    I tried adding it to the load event, but that seems to never get fired. I added it to the zoomend event which seems the one that gets triggered right at the end of rendering but the exports still show empty.

    0
    Comment actions Permalink

Please sign in to leave a comment.