When trying to generate a PDF via a scheduled task I get the following error (in my production application):
server_log-ERROR 2023-01-05 09:01:53: AnvilWrappedError: 'Invalid print session' for order 10885
I attempted to make a simple clone to repeat the issue, but it yielded a different error:
CallMethodException: PDF generation failed: calling method: Page.navigate error: Cannot navigate to invalid URL
at /downlink/anvil/pdf.py, line 17
called from /downlink/anvil/pdf.py, line 34
called from ServerModule1, line 25
Here is the clone code:
@anvil.server.callable
@anvil.server.background_task
def create_pdf():
pdf = anvil.pdf.render_form('Form1')
return pdf
The clone also has a button that calls this method and downloads the pdf successfully.
This error also appears when trying too call the method from a server console.