How to send email with invoice PDF attachement in Zoho CRM Deluge?

How to send email with invoice PDF attachement in Zoho CRM Deluge?

// I am creating the invoice here

response = zoho.crm.createRecord("Invoices",values);

// trying to get the PDF version

fileUrl = "https://www.zohoapis.eu/crm/v3/invoices/" + response.get("id") + "/pdf";
invoiceFile = invokeUrl(fileUrl,"GET").toFile("Test.html");

// send that file via email

sendmail
[
from :zoho.adminuserid
subject :"Membership invoice"
message :"There is the new invoice"
Attachments :file:invoiceFile
]

I get the email, but the PDF is blank.

No matter what I try, the attachement is not a properly created PDF. How can we create and attach PDF of the invoice created?