164
Views
11
Comments
Solved
[Ultimate PDF] Trying to delay the print of a page
ultimate-pdf
Reactive icon
Forge component by Leonardo Fernandes
Application Type
Reactive

Hi.
I am using the reactive version of this component and I am trying to delay the print of the page because I have Web blocks rendering charts and some information is not ready when the screen is printed.
I am using two client actions available on the component, where I use IsReadyForCapture when all charts are rendered


But I am getting a timeout waiting for selector 'body:not(.ultimate-pdf-is-not-ready)' failed: timeout 30000 ms exceeded 

Any ideas on how I can increase this value or if there is other solution?


Thanks.

Solution

Hi Sara. You will need to detect when the chart has fully rendered, and at that moment invoke the action IsReadyForCapture.

Ideally the chart would expose an event that is triggered when the chart was rendered. But if that is not the case, you could try a solution using window.setInterval() and checking if the chart has rendered every 100ms, and if so, call IsReadyForCapture.

Hi Sara Rodrigues ,

you can use " sleep" forge component to delay your execution for as long time as you want.

It take a input parameter integer data type    

you provide input as Millisecond  like 1 sec= 1000ms

Sleep forge component link:

https://www.outsystems.com/forge/component-overview/1244/sleep


Solution

Hi Sara. You will need to detect when the chart has fully rendered, and at that moment invoke the action IsReadyForCapture.

Ideally the chart would expose an event that is triggered when the chart was rendered. But if that is not the case, you could try a solution using window.setInterval() and checking if the chart has rendered every 100ms, and if so, call IsReadyForCapture.

Hi,

I'm having the same problems. I've tried JS sleep scripts, on render, and on ready, but the UltimatePDF is still printing the screen before the animations have completed, and the charts are therefore incomplete.

Were you able to figure something out?

Thank you

Hi Leigh Rogers.

Have you tried the solution that was described in this thread?

Hi Leonardo and thank you for your prompt reply. I understand the principle of the answer, but not how to execute it?

How would we be able to detect if it is fully rendered, and how would we invoke the is ready for capture?

Edit: Added----

I've tried several things before. Here's my latest attempt:


I've verified in the logs that the sleep function works, and it's set to 10 seconds.

The output of the UltimatePDF file changes every execution. The last two look like this:





I assume the graphs look different because they're still being animated during the PrintPDF execution.

I'd be grateful for any direction you can offer.

Thank you

I recommend you to turn off the chart animations.

You can probably periodically query the nodes created by the chart, to identify when the chart is fully rendered.

Can you help me with how to do this, please?

I actually thought I'd already done it with this screenshot, but that doesn't seem to make any difference.


Keep that setting DisableLoadingAnimation = True, that helps to some extent.

Make sure you invoke WaitUntilReadyBeforeCapturing inside the OnInitialize of the screen.


Try using the action SetHighchartsChartConfigs to disable the animation. Invoke it inside the ChartInitialized event like so:


After all charts are initialized, you can invoke the action IsReadyForCapture.

Thanks Leonardo.

I've done the following:

  1. Added WaitUntilReadyBeforeCapturing in the screens OnInitialize action
  2. Added ChartInitialize events for each of the four pie charts and configured the AddOns/SetHighchartsChartConfigs as per your screenshot.
  3. Added a screen OnReady action, which includes a sleep function with 10 second delay, before using the isReadyForCapture action.

There's still no change; UltimatePDF still prints too early, meaning the images are not rendered fully.

Just for the avoidance of doubt, and in case I've done something daft:


On Screen Initialize 


On Chart Initialize

On Screen OnReady


The alternative is to disable the charts, but it seems a shame to do this.

Let me see how you've implemented the Sleep action, I suspect it's not sleeping at all.


Note that the best option is not to use any Sleep at all. After the 4 charts are initialized, you can call IsReadyForCapture. To do that, you can have a count of initialized events on the screen (InitializedCharts), and also a count of charts (TotalCharts) initialized to 4 in your case. On each PieInitialized event, increment InitializedCharts, and check whether InitializedCharts = TotalCharts, and if so, invoke IsReadyForCapture.

Hi, i am a  novice . In tradition how to trying to delay the print of a page 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.