[FIXED] Invalid print session

I am experiencing this as well when creating PDFs. I can’t so easily share a clone link or a link to the app because it is an internal tool behind login credentials.

the error happens on the last line pdf = a.render_form(‘’) . This is called during a background task.

@anvil.server.callable
def add_engagement_letter(claim, attorney):
  
  claimant_name='{} {}'.format(claim['claimant']['first_name'], claim['claimant']['last_name'])
  a = anvil.pdf.PDFRenderer(filename='{} ({}) Engagement Letter.pdf'.format(claimant_name, claim['reference_id']))
  replacements = {'*Date*':datetime.date.today().strftime('%B %d, %Y'),
                  '*Customer Name*':claimant_name,
                  '*Customer Email*':claim['claimant']['email'],
                  '*Customer Phone*':claim['claimant']['phone_number'],
                  '*Attorney Name*':attorney['name'],
                  '*Company Name*':claim['company']['entity_name'],
                  '*Attorney Email*':attorney['email']
                 }
  
  signature=claim['signature']
  pdf = a.render_form('attorney_engagement',signature, replacements)