DataMagik Documents

Last updated: October 6, 2025

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

Advanced Features

Templates & Examples

  • 07. Starter Templates - Ready-to-use templates for common documents
  • Invoice Template
  • Receipt Template
  • Report Template
  • Letter Template
  • Contract Template

Integration Guides

🚀 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

  1. Design - Create HTML structure with CSS styling
  2. Add Variables - Insert {{.VariableName}} placeholders
  3. Define Schema - Specify expected data structure in JSON Schema
  4. Create Sample Data - Provide example JSON for testing
  5. Preview - Test template rendering with sample data
  6. Commit - Save version to template library
  7. Integrate - Call API to generate documents programmatically

📦 Available Template Functions

Text Functions

  • upper - Convert to uppercase
  • lower - Convert to lowercase
  • title - Title case
  • printf - Format strings with placeholders

Date Functions

  • dateFormat - Format dates with custom layouts

Chart Functions

  • lineChart - Line charts
  • barChart - Bar charts
  • pieChart - Pie charts
  • doughnutChart - Doughnut charts
  • chart_line - CSV-based line charts
  • chart_bar - CSV-based bar charts
  • chart_pie - CSV-based pie charts

Barcode Functions

  • code128 - Code 128 barcodes
  • code39 - Code 39 barcodes
  • qrcode - QR codes
  • datamatrix - Data Matrix barcodes
  • ean13 - EAN-13 barcodes
  • pdf417 - PDF417 barcodes

Control Flow

  • if/else/end - Conditional rendering
  • range/end - Loop through arrays
  • with/end - Set context for nested objects

🔗 Related Resources

💡 Tips & Best Practices

  1. Test Templates Thoroughly - Always preview with sample data before production use
  2. Keep Templates Simple - Complex logic should be in your application, not templates
  3. Use Semantic HTML - Proper HTML structure ensures better PDF rendering
  4. Optimize Images - Use base64 for small images, URLs for large ones
  5. Consider Page Breaks - Use CSS page-break-after for multi-page PDFs
  6. Cache Generated Documents - Set force_regenerate: false for repeated requests
  7. 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

Was this page helpful?