Print_media function does not work constantly

Dear guys,

I cannot put this post into bug reports, therefore I list it here. In my case the anvil.media call print_media seems to not work constantly. At first the below showed code works fine until some timeout (after 15-30 minutes) an internal error arises (code below). Do anybody of you know what the reason could be or if this function is still in process?

CODE SNIPET:

try:
   print('Before printing')
   anvil.media.print_media(resp)
   print('After printing')
except Exception as e:
   print('Error printing bill media',e)

CONSOLE OUTPUT:

  • Before printing
  • [An internal error has occurred] - see browser console for more details
  • TypeError: Cannot set properties of null (setting 'onload') at t.onclick (https://anvil.works/runtime-new/runtime/js/runner.bundle.js?sha=1d34bbf7955d709194fa6f33c295a7c7d7ca27deed452172d385f2a7192b0741:346:413) at Arguments.<anonymous> (https://anvil.works/runtime-new/runtime/js/runner.bundle.js?sha=1d34bbf7955d709194fa6f33c295a7c7d7ca27deed452172d385f2a7192b0741:346:506) at Sk.misceval.chain (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:473:454) at $meth (https://anvil.works/runtime-new/runtime/js/runner.bundle.js?sha=1d34bbf7955d709194fa6f33c295a7c7d7ca27deed452172d385f2a7192b0741:346:71) at sk_method.$callOneArg (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:315:449) at $date_link_click60790$ (eval at <anonymous> (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:1089:392), <anonymous>:526:42) at susp.resume (eval at <anonymous> (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:1089:392), <anonymous>:373:1826) at l (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:471:443) at n (https://anvil.works/runtime-new/runtime/js/lib/skulpt.min.js?sha=2b09aa0590c8a83c7a4a5fbee77f64faf07023095aff414e73e1de34f0526383:472:1)
  • After printing

I haven’t tried print_media(), but when printing from Firefox, sometimes Firefox locks up, and sometimes Firefox locks up the printer. Could this be your problem?

In my case it occured in Chrome. I also tried it with another library where everything works fine so most likely it has something to do with print_media(). But thanks for your response!

I’m experiencing this error consistently in Chrome and Safari after publishing. It works in preview mode in the Anvil IDE. The form I’m producing with print_media is dense. It only has a few pages, but it includes aprox. 400 textboxes and 11 pictures. An suggestions on how get around this problem? Many thanks.

Replaced the call to anvil.media.print_media(my_pdf) with anvil.media.download(my_pdf) and that solved the problem.