Generating PDFs from WordPress is always harder than it should be
You want branded invoices on your WooCommerce orders. You research the options. Every path ends badly: a premium PDF plugin with recurring fees, a free plugin with ugly default templates, or a custom DOMPDF integration you'd have to build and maintain yourself.
And that's just invoices. Next month you'll want shipping labels. Then event tickets. Then certificates for a membership site. Each one wants its own specialized plugin.
What most people do instead
A better way: design once, generate from any macro
Build your PDF template in the drag-and-drop Email Template Builder (PDF type). Add dynamic tags like {{customer_name}}, {{order_total}}, {{order_items}}. Then the generate pdf command creates a PDF from that template, with the dynamic tags filled from trigger data or upstream chain results.
customer_name, order_total, order_items (x5), invoice_date{{step1.file_path}}, {{step1.file_url}}Designed for macros. The generated PDF's path and URL are exposed as chain results (step1.file_path, step1.file_url). The next step can attach the PDF to an email, upload it to S3 via send-api, or save it to user meta.
How it works
The command takes a saved template (built in the PDF type of the Template Builder), fills dynamic tags from the current macro context, and renders via the bundled DOMPDF library. Generated PDFs save to the uploads directory with a time-stamped filename. The path + secure download URL flow to downstream steps.
{{dynamic_tags}} anywhere.step1.file_path is ready for the next step.| Parameter | Value |
|---|---|
-template_id | ID of a saved PDF template |
| Dynamic tag resolution | Trigger context + upstream chain results auto-fill tags at render time |
| Storage | uploads/trc/pdfs/ with time-stamped filename |
| Returns | file_path (filesystem), file_url (secure download link) |
| For-each support | Yes — generate one PDF per item in an array (one per order, one per user) |
| Can be used in |
Real example
You want every WooCommerce order to trigger an automated invoice PDF sent to the customer.
Template: you design a one-page invoice in the builder — logo, order number, date, customer info, line items, total. Every variable is a {{tag}}. Save as "Customer Invoice v1".
Macro: triggered by "woocommerce_order_paid". Step 1 is generate pdf with the invoice template. Step 2 is send template email with a "Your invoice is attached" email, and {{step1.file_path}} as the attachment.
Set it once. Every paid order generates a branded PDF invoice and emails it to the customer. You never touch it again.