Run Web block preparation before Page preparation

Run Web block preparation before Page preparation

  

Hi.

I'm currently using some graphs in a web block, which is present on a page.

This page is being converted into a PDF to send as part of a report using this forge component.

Unfortunately, the PDF is being generated before the graphs render.

It seems that the page preparation is running before the web block preparation. So the graphs are empty.

So is it possible to run the web block preparation first, or add a delay to the page preparation, to continue until the graphs have been rendered?

Hi Saurav,

At which event you are trying to generate the pdf from html? 

Full html would only be rendered after the execution of  preparation of both page and web block . So you can generate the pdf on button click by Ajax Submit or if you need to do that after page load then trigger a FakeNotificationEvent or a button click event from Javascript page load event

Regards

Devendra


Hi Saurav,

I think you do not understood how this works.

1. In a server action you will use the action from HTML2PDF component passing an URL to it, in order to create the PDF based on that page.

2. The action will than execute an executable in server passing the URL, and the executable will request the page to the server.

3. The server, when receiving the request, will run the PREPARATION of the page, and than will start to construct the HTML. When, during the construction of the HTML, the server founds a Web Block, it will run the preparation of the Web Block and than will construct the HTML provided by the Web Block into the PAGE.

4. After finishing the HTML build phase, the server will return the page HTML to the executable that made the request

5. The executable will take this HTML, and will convert it to PDF, returning the PDF to the action that called it.

6. Your action (the first one) now have the PDF and you can download it or send through email, for example.

So, as you can see, the preparation of the web block can not be called before the preparation of the page, and the page is fully build before it is converted in PDF.

So, maybe, the problem is different.

First thing you need to remember is:

When the executable request the page, this will be done OUTSIDE the current session, so there will be no logged user when the page is built. This means that any data you need to construct the page, based on the logged user id, can not be done using the GetUserId. Also, the Session variables will be all with the default values, so you can't use them either.

You will have to pass the user ID or any other information through parameters in the URL or through database.
No other way.

Hope this can be of help.

Cheers.