If you want to allow a user to continue working while generating the document, you could do something like this:
- In the generate PDF flow you create the object that will hold the PDF file,
- Set a 'in progress' status on this object and commit it.
- Generate the PDF in the background. Once that has successfully completed, set a 'done' status (furthermore, if an error occurs, you can set a 'failed' status).
- In the user interface of the user, you can show a Data Grid of the object you created. In this grid, the user sees the status of the document (so 'in progress', 'done' or 'error'). You can add a refresh timer of e.g. 30 seconds, so that the status refreshes automatically when it changes.
- If the document is 'done', the user can download it.