How we can send reports from server script?

I want to send sales invoices in emails along with payment history to my clients using server script. I have created a report for payment history. Now I want to send emails from server script to my clients containing sales invoices and payment history. I can send the sales invoice but I am not finding a way to send a report as a pdf from the server script. can anyone help me to solve my requirement?

Hi. So have you found the solution in this? I am having the same requirement.

so this is how I am sending email containing sales invoice from server script

attachments=[]

attachments.append(frappe.attach_print(doc.doctype, atchmnt.name, file_name=atchmnt.name, print_format=print_format, print_letterhead=True))

   frappe.sendmail(
           sender=<sender_email>,
           recipients=contact_emails,
 	    message=message,
 	    subject="Sales Invoice",
           attachments=attachments,
 	    expose_recipients="header"
   	)