Almost every Creator app eventually has to hand someone a document — an invoice, a work order, a signed agreement, a summary the client wants to keep. Creator will produce all of these as PDFs without any external service. There are three patterns worth knowing, and picking the wrong one is what makes this feel harder than it is.
Written from scratch. The original library entry for this topic was a title and nothing else — no script, no explanation. It was also flagged unpublished in the source platform, so it never reached anyone. This article is new.
If the PDF only needs to reach a person, do not generate a file at all. sendmail renders a report template straight into an attachment:
// Trigger: a button on a report, or On Success of a form
// Email a report template as a PDF attachment
sendmail
[
from : zoho.adminuserid
to : input.Client_Email
subject : "Your invoice " + input.Invoice_Number
message : "<p>Hi " + input.Client_Name + ",</p><p>Your invoice is attached.</p>"
Attachments : template:InvoicePrint as PDF
]The template is an ordinary Creator report template, so you lay it out visually and Deluge never touches the formatting. This covers the majority of real cases.
When the document has to be stored, sent to another API, or base64-encoded for an e-signature service, fetch it as a file object:
// Fetch the PDF as a file object, then do anything you like with it
void PDF.archiveInvoice(int recordId)
{
pdfFile = invokeurl
[
url : "https://creatorapp.zohopublic.com/YOUR_ACCOUNT/YOUR_APP/report/Invoices/" + recordId + "/pdf"
type : GET
connection : "creator_oauth_connection"
];
// a) Attach it back onto the record's file-upload field
rec = Invoices[ID == recordId];
rec.Invoice_PDF = pdfFile;
// b) or push it to WorkDrive
uploadResp = invokeurl
[
url : "https://www.zohoapis.com/workdrive/api/v1/upload?filename=Invoice-"
+ rec.Invoice_Number + ".pdf&parent_id=YOUR_WORKDRIVE_FOLDER_ID"
type : POST
files : pdfFile
connection : "workdrive_connection"
];
info uploadResp;
// c) or base64 it for an API that wants an inline document
docBase64 = zoho.encryption.base64Encode(pdfFile);
info "base64 length: " + docBase64.length();
}Sometimes the answer is not automation. A report’s built-in Print action already renders any template to PDF on demand, and a button that calls openUrl on the print URL gives the user a preview they can save themselves. Do not write Deluge for something the platform already does.
documentBase64; Acrobat Sign wants a multipart upload to transientDocuments; Zoho Sign takes the file object directly. All three start from pattern 2.This script is part of the free Creator Scripts Deluge Library.
All 39 Deluge scripts, the full Zoho Creator course, and every downloadable asset are now free. Get free access →