-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait for condition before printing #6
Comments
So I'm now taking the approach of adding command line and http request options which cause cef-pdf to produce the pdf when it receives the When these options are used the frame in question will need to evaluate |
Trying to work this out (I don't have C++ experience) master...beckyconning:Remote-trigger Is where I am up to right now but when run with |
I just can find the reason behind that feature. What do you need it for? |
To produce PDFs from DOMs produced by javascript applications which use data from http requests of arbitrary duration (could be 0.5 seconds, could be 30 minutes). Although this could be achieved by transforming that DOM into static HTML (canvas -> img etc) and then passing a data uri or making a post request with this HTML in the body this can not be done non interactively (e.g. on a schedule) without yet another automated browser. This is akin to a selfie taken by the subject via remote trigger rather than a photo which is taken by someone else as soon as the subject is seen (loaded). |
This allows javascript applications to tell cef-pdf when they are ready to be rendered as a PDF. |
|
Any javascript application can include a print layout via a Think of all the Javascript applications out there which would benefit from this : ). |
This is now working, just need to add the http option argument and tidy up. master...beckyconning:trigger-remote |
Then I will submit a PR. |
@beckyconning I have made some adjustment to your code 4d7ee11 but i'm unable to make the trigger work (under Windows). Can you test this on |
http://magpcss.org/ceforum/apidocs3/projects/(default)/CefClient.html#OnProcessMessageReceived(CefRefPtr,CefProcessId,CefRefPtr) Both |
@spajak does the above solve this issue? |
But I have |
Try separating them.
…Sent from my iPhone
On 1 Sep 2017, at 18:55, Sebastian Pająk ***@***.***> wrote:
But I have CefClient and CefRenderProcessHandler separated
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Didn't work. Did you tried this feature on Windows? |
I wasn't able to compile this on Windows. Besides this feature needs more work. Like some timeout for example, without this, when the callback is never called |
Why not? If the HTTP connection is closed then it is cancelled, if the process receives SIGINT it is cancelled. Why is it |
Closing http connection does not cause renderer process to quit. cef-pdf starts additional process for every job. It is also responsible for closing the process, otherwise the process runs forever |
Ah I see. Shouldn't that be the priority then? Surely if the HTTP connection is closed there is no need for the job process? |
What you describe could happen already if loading the page takes infinite time. |
Like even without remote-trigger. |
So the client should be able to abort and cause cleanup by closing the collection. |
Ah I found the bug. All the trigger stuff was working fine but the convenience function was being put on the window object of about:blank rather than the window object of the given web page. |
I must have been testing with the full expression rather than the convenience function. |
Regarding timeouts please consider these scenarios: Direct connection to PDF generator: A timeout prevents successful PDF generation. Direct connection to PDF generator: Successful PDF generation. Direct connection to PDF generator: User impatience prevents successful PDF generation. If processes and resources dedicated to the generation of this PDF are not cleaned up when the connection is dropped the PDF generation will continue wastefully for 2 minutes despite no-one ever receiving this PDF. Indirect connection from app to PDF generator: Successful PDF generation The application server is set to allow 1000 concurrent PDF generations. Currently there are 1000 generations in progress. The application server cancels the longest running generation which has been in progress for over 10 minutes to make room for Saiid's PDF (if no generation had been running for more than 10 minutes then Saiid's generation would pend until either a generation finished or lasted more than 10 minutes). This generation was started by a user called Hadil. If Hadil checks the app now she will be informed that her PDF was taking a long time to produce and that it will be reattempted when the service is less busy. The application informs the administrator that this has occurred so the administrator can decide whether to increase the generation capacity of this service or not. The application then starts generating Saiid's PDF. Whilst this is happening 700 generations finish successfully after which only 10 more are started. The service is now less busy so the server reattempts Hadil's PDF generation. 10 minutes later Saiid launches the app and finds his PDF ready to download. 30 minutes later Hadil launches the app and finds her PDF ready to download. If generation cancellation was based only on time rather than on the server capacity and time neither of these PDF would never have been successfully generated. |
cef-pdf could decide to implement a more thoughtful cancellation policy such as the one described in the last scenario. However it has no obligation to and applications may wish to implement their own differing policy. In many cases a cancellation policy based solely on connection is sufficient. If we're still waiting for the pdf then please keep trying to produce it is sensible. If it is not sufficient this policy can be used by other applications to produce any other cancellation policy. Separation of concerns is important and providing even an optional timeout is dangerous as it encourages misuse. If anyone wants to use a timeout cancellation policy they can implement it themselves trivially. Via HTTP curl and wget provide timeouts and ajax timeouts are easy to implement in javascript and other languages. When timeout is exceeded the connection is closed after which cef-pdf should clean up. Via the command line these examples work pretty well. bash
timeout
windows
|
One approach would be to add a command line option which takes a javascript expression which returns a boolean. This expression would be repeatedly evaluated until it returns true at which point the PDF would be generated.
I'd love to help make this a thing and will be investigating how to do it now. Any help or guidance through the source would be very appreciated.
The text was updated successfully, but these errors were encountered: