afratafreeh serve --port 4000 Visit http://localhost:4000/edit?template=draft.afd to see live changes. Even advanced users hit snags. Here’s how to fix them:
"user": "name": "Alex Johnson" Run the command: Afratafreeh Doc Tutorial-
afratafreeh render -t problem.afd -d data.json --debug Use Case 1: Automated Legal Contracts Problem: A law firm needs to generate NDAs for 50 different counterparties. Solution: Create a master nda_template.afd with placeholders ( party_a , effective_date ). Use a CSV loop and the batch command. Use Case 2: E-commerce Order Summaries Problem: Send a styled HTML receipt via email plus a PDF attachment. Solution: Generate once, output to both formats: Solution: Create a master nda_template
afratafreeh render -t contract.afd -d client.json -o contract.pdf --secure --watermark "CONFIDENTIAL" --password-protected Develop templates faster using hot reload: Solution: Generate once, output to both formats: afratafreeh
% include "header.afd" % <main>Dynamic content here...</main> % include "footer.afd" % 4.1. Batch Document Generation Generate 1000 custom invoices from a CSV:
module.exports = name: 'toEUR', exec: (amount, rate = 0.92) => amount * rate ; In your template: 100 → 91 For sensitive PDFs, use the --secure flag:
number_format(2) → $1,234.50 Conditional Logic % if order.status == 'shipped' % <div class="success">Your order is on the way.</div> % elif order.status == 'pending' % <div class="warning">Processing...</div> % else % <div class="error">Contact support.</div> % endif % Loops (Iteration) Loop through arrays to build tables dynamically: