What I’m trying to do:
I’ve created a form that is comprised of textboxes populated from a user datatable. However, when I go to download this as a PDF, I keep getting errors.
Does anyone have an actual solution to this? I’ve read all the forum posts and links, and nothing works. It doesn’t make sense that this can’t generate even the most basic form (even when I trial a new form, ‘Form1’, its still an error. Is there something glaring I’m doing wrong?
As you can see- it’s not a complicated PDF. It’s just textboxes populated with text from a datatable!
ERROR: “Exception: PDF generation failed: Components did not load within allowed time.
at /downlink-sources/downlink-2023-10-05-18-37-23/anvil/pdf.py, line 17
called from /downlink-sources/downlink-2023-10-05-18-37-23/anvil/pdf.py, line 59”
What I’ve tried and what’s not working:
I’ve tried everything, and read the docs.
- I’ve tried basic client side code.
media_object = anvil.pdf.render_form('Form1', 42, name='Zaphod')
- Then, I tried it with a background task (see code snippet below). Still received the same error:
Generate PDF background task started
Warning: No method "main_headline_group_change" in form FinalProduct_Export: cannot set the 'change' event handler of self.main_headline_textbox.
Exception: PDF generation failed: Components did not load within allowed time.
at /downlink-sources/downlink-2023-10-05-18-37-23/anvil/pdf.py, line 17
called from /downlink-sources/downlink-2023-10-05-18-37-23/anvil/pdf.py, line 34
called from FunnelServer, line 74
- Then, I tried with PDFRenderer
pdf = PDFRenderer(page_size='A4').render_form('FinalProduct_Export_test')
Same error. Not really sure why this seems to be so complicated for me. Does anyone have any insight?
Code Sample:
Is there an issue with what I’m calling the forms? For example, I’ve called form “FinalProduct_Export_test” in my PDF export, which refers to:
class FinalProduct_Export_test(FinalProduct_Export_testTemplate):
def download_vsl_pdf_click(self, **event_args):
self.task_id = anvil.server.call('launch_download_vsl_pdf',self.user_table)
SERVER SIDE:
@anvil.server.callable
def launch_download_vsl_pdf(user_table):
task_id = anvil.server.launch_background_task('generate_pdf_to_download',user_table)
return task_id.get_id()
@anvil.server.background_task
def generate_pdf_to_download(user_table):
print("Generate PDF background task started")
media_object = anvil.pdf.render_form('FinalProduct_Export_test')
return media_object