Afratafreeh Doc Tutorial- May 2026

module.exports = name: 'toEUR', exec: (amount, rate = 0.92) => amount * rate ; In your template: toEUR(0.91) → 91 For sensitive PDFs, use the --secure flag:

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: Afratafreeh Doc Tutorial-

| Filter | Input | Output | |--------|-------|--------| | upper | name → "john" | "JOHN" | | capitalize | city → "paris" | "Paris" | | default('N/A') | middle_name (null) | "N/A" | | number_format(2) | 1234.5 | "1,234.50" | module

| Error Message | Likely Cause | Solution | |---------------|--------------|----------| | SyntaxError: Unexpected token '%' | Mismatched tags (e.g., {% if closed with endif ) | Use % endif % ; check opening/closing braces. | | KeyError: 'user.email' | Missing data in JSON path. | Use safe navigation: user.email \ | | Cannot find module '@afratafreeh/pdf-renderer' | Missing PDF backend. | Run npm install @afratafreeh/pdf-renderer | | Output truncated at 5000 pages | Loop generating infinite rows. | Check your % for % condition; add [:100] to limit: items[:100] | Use Case 2: E-commerce Order Summaries Problem: Send

"user": "name": "Alex Johnson" Run the command:

afratafreeh render -t contract.afd -d client.json -o contract.pdf --secure --watermark "CONFIDENTIAL" --password-protected Develop templates faster using hot reload: