DataMagik Documents
DataMagik Document Designer - Complete Documentation
Welcome to the comprehensive guide for the DataMagik Document Designer! This documentation covers everything you need to create powerful, dynamic document templates with barcodes, charts, and advanced formatting.
📚 Table of Contents
Getting Started
- 01. Go Template Syntax - Master the template language fundamentals
- 02. String Functions - Text manipulation and formatting
- 03. Date & Time Functions - Format dates and timestamps
- 04. Control Flow - Conditionals, loops, and data structures
Advanced Features
- 05. Barcode Generation - Generate Code 128, QR codes, EAN-13, and more
- 06. Chart Generation - Create line charts, bar charts, pie charts, and doughnut charts
Templates & Examples
- 07. Starter Templates - Ready-to-use templates for common documents
- Invoice Template
- Receipt Template
- Report Template
- Letter Template
- Contract Template
Integration Guides
- 08. API Reference - Complete REST API documentation
- 09. N8N Integration - Workflow automation with n8n
- 10. Automation Setup - Configure automations, actions, webhooks, and navigation
🚀 Quick Start
1. Basic Template Example
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello, {{.Name}}!</h1>
<p>Welcome to DataMagik Document Designer.</p>
</body>
</html>
2. With Sample Data
{
"Name": "John Doe"
}
3. Generate Document via API
curl -X POST https://your-app.com/api/document-designer/generate \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"template_id": 123,
"format": "pdf",
"data": {
"Name": "John Doe"
},
"return_type": "url"
}'
📖 Key Concepts
Template Variables
Access data using {{.VariableName}} syntax:
<p>Customer: {{.CustomerName}}</p>
<p>Invoice: {{.InvoiceNumber}}</p>
<p>Amount: ${{.TotalAmount}}</p>
Looping Through Arrays
Use {{range}} to iterate over collections:
<table>
{{range .Items}}
<tr>
<td>{{.Description}}</td>
<td>{{.Quantity}}</td>
<td>${{.Price}}</td>
</tr>
{{end}}
</table>
Conditional Logic
Use {{if}} for conditional rendering:
{{if .IsPaid}}
<span class="badge-success">PAID</span>
{{else}}
<span class="badge-warning">PENDING</span>
{{end}}
Barcodes
Generate barcodes with simple function calls:
<!-- Code 128 barcode -->
{{code128 .OrderNumber 300 100}}
<!-- QR Code -->
{{qrcode .TrackingURL 200}}
Charts
Create data visualizations:
<!-- Bar chart from data -->
{{barChart .SalesData "salesChart" 800 400}}
<!-- Line chart from CSV -->
{{chart_line "Monthly Sales" "Jan,100|Feb,150|Mar,200" 800 400}}
🎯 Common Use Cases
1. Invoices & Receipts
Generate professional invoices with line items, calculations, and barcodes for tracking.
2. Reports & Analytics
Create data-driven reports with charts, tables, and formatted metrics.
3. Certificates & Badges
Design certificates with dynamic names, dates, and QR codes for verification.
4. Shipping Labels
Generate shipping labels with addresses and tracking barcodes.
5. Contracts & Agreements
Create legal documents with conditional clauses and signature blocks.
🛠️ Template Development Workflow
- Design - Create HTML structure with CSS styling
- Add Variables - Insert
{{.VariableName}}placeholders - Define Schema - Specify expected data structure in JSON Schema
- Create Sample Data - Provide example JSON for testing
- Preview - Test template rendering with sample data
- Commit - Save version to template library
- Integrate - Call API to generate documents programmatically
📦 Available Template Functions
Text Functions
upper- Convert to uppercaselower- Convert to lowercasetitle- Title caseprintf- Format strings with placeholders
Date Functions
dateFormat- Format dates with custom layouts
Chart Functions
lineChart- Line chartsbarChart- Bar chartspieChart- Pie chartsdoughnutChart- Doughnut chartschart_line- CSV-based line chartschart_bar- CSV-based bar chartschart_pie- CSV-based pie charts
Barcode Functions
code128- Code 128 barcodescode39- Code 39 barcodesqrcode- QR codesdatamatrix- Data Matrix barcodesean13- EAN-13 barcodespdf417- PDF417 barcodes
Control Flow
if/else/end- Conditional renderingrange/end- Loop through arrayswith/end- Set context for nested objects
🔗 Related Resources
- API Integration Guide - Detailed API reference
- N8N Integration Guide - N8N workflow examples
- Automation Implementation Guide - Backend automation details
💡 Tips & Best Practices
- Test Templates Thoroughly - Always preview with sample data before production use
- Keep Templates Simple - Complex logic should be in your application, not templates
- Use Semantic HTML - Proper HTML structure ensures better PDF rendering
- Optimize Images - Use base64 for small images, URLs for large ones
- Consider Page Breaks - Use CSS
page-break-afterfor multi-page PDFs - Cache Generated Documents - Set
force_regenerate: falsefor repeated requests - Set Appropriate TTL - Configure document expiration based on sensitivity
📞 Support
For questions, issues, or feature requests:
- Check the detailed documentation in each section
- Review the starter templates for examples
- Contact the development team for integration support
Version: 1.0.0
Last Updated: 2025
License: Proprietary - DataMagik Platform