# DMD - Document Markdown

A specialized markdown language for generating professional PDF documents. DMD extends markdown with powerful features for document layout, styling, and formatting.

[![npm version](https://img.shields.io/npm/v/dmd-to-pdf.svg)](https://www.npmjs.com/package/dmd-to-pdf)
[![License](https://img.shields.io/badge/license-Proprietary-blue.svg)](LICENSE)

## Installation

**Requirements:** pdfmake 0.3.5 or higher

```bash
npm install dmd-to-pdf pdfmake@0.3.5
```

**CDN (Browser):**
```html
<script src="https://cdn.jsdelivr.net/npm/pdfmake@0.3.5/build/pdfmake.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dmd-to-pdf/dist/dmd.umd.js"></script>
```

## Quick Start

**Browser:**
```javascript
// DMD is available as global after loading the script
const document = `
:::config
title: My Document
author: John Doe
:::

# Hello World

This is a **DMD** document with *rich formatting*.

## Features

- Simple markdown syntax
- Professional PDF output
- Tables, lists, and more
`;

// Generate PDF
const pdfBlob = await DMD.createPdf(document);
```

**Node.js:**
```javascript
// Setup pdfmake
const pdfmake = require('pdfmake');
const vfsFonts = require('pdfmake/build/vfs_fonts');
pdfmake.vfs = vfsFonts.pdfMake.vfs;

// Import DMD
const DMD = require('dmd-to-pdf');

const pdfBuffer = await DMD.createPdf('# Hello World');
```

## Free vs Pro Features

| Feature | Free | Pro |
|---------|:----:|:---:|
| Basic markdown (headings, text, lists) | ✓ | ✓ |
| Document config (title, margins, page size) | ✓ | ✓ |
| Basic tables | ✓ | ✓ |
| Multi-column layouts | ✓ | ✓ |
| Images & SVG | ✓ | ✓ |
| Links | ✓ | ✓ |
| Headers & footers | ✓ | ✓ |
| Inline styling `[text]{::style}` | ✓ | ✓ |
| **Custom fonts** (non-Roboto) | - | ✓ |
| **Watermarks** | - | ✓ |
| **Background layers** | - | ✓ |
| **Table of contents & bookmarks** | - | ✓ |
| **QR codes** | - | ✓ |
| **Block styling** `::style-name` | - | ✓ |
| **Table/list/column styling** | - | ✓ |

### Enabling Pro Features

```javascript
// Set your license key to enable Pro features
const result = await DMD.setLicense('DMD-XXXX-XXXX-XXXX-XXXX');

if (result.valid) {
  console.log('Pro features enabled!');
}
```

Get a license at [dmdlang.dev/pricing](https://dmdlang.dev/#pricing)

## API Reference

### `DMD.createPdf(source, format?)`
Generate a PDF from DMD source.
- `source` - DMD formatted string
- `format` - Output format: `'blob'` (default), `'base64'`, `'dataUrl'`, `'buffer'` (Node.js)

### `DMD.extractConfig(source)`
Extract metadata and config without generating PDF.

### `DMD.loadImages(imageMap)`
Preload images for better performance.
```javascript
await DMD.loadImages({
  logo: 'https://example.com/logo.png',
  banner: '/images/banner.jpg'
});
```

### `DMD.loadFonts(fontMap)`
Load custom fonts. **(Pro)**
```javascript
await DMD.loadFonts({
  'MyFont': {
    normal: 'https://example.com/font.ttf',
    bold: 'https://example.com/font-bold.ttf'
  }
});
```

### `DMD.setLicense(key)`
Set and validate a license key.

### `DMD.isPro()`
Check if Pro features are enabled.

See full documentation at [dmdlang.dev](https://dmdlang.dev)

## DMD Syntax

```
:::config
title: Document Title
author: Author Name
pageSize: A4
pageMargins: [40, 60, 40, 60]
:::

:::styles
title:
  fontSize: 24
  bold: true
  color: "#333333"
:::

# [Document Title]{::title}

Regular paragraph with **bold** and *italic* text.

## Lists

- Item one
- Item two
  - Nested item

## Tables

::table
Name | Age | City
Alice | 30 | New York
Bob | 25 | London
::

## Links

[Visit our website]{url: https://dmdlang.dev}

## Images

[Company Logo]{img: logo}
```

## Documentation

- **Website**: [dmdlang.dev](https://dmdlang.dev)
- **Playground**: [dmdlang.dev/#playground](https://dmdlang.dev/#playground)
- **Reference**: [dmdlang.dev/#reference](https://dmdlang.dev/#reference)
- **LLM Context**: [dmdlang.dev/llms.txt](https://dmdlang.dev/llms.txt)

## License

This software is proprietary. See [license terms](https://dmdlang.dev/#license) for details.

- **Free Features**: Available for personal and commercial use
- **Pro Features**: Require a valid license key

Copyright (c) 2026-present JSA DESENVOLVIMENTO DE SOFTWARES LTDA. All rights reserved.
