by luyike ยท v1.1.0
Smart document generator with automatic chart generation from Markdown to Word
This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.
Available inside your emploidai workspace after installation.
Available inside your emploidai workspace after installation.
A smart Markdown to Word document generator with automatic chart generation (pie charts, bar charts, line charts) and flexible template mechanism, enabling rapid generation of formatted Word documents with rich visualizations for various scenarios.
Repository: https://github.com/luyike221/dify_markdown_to_word_plugin.git
Smart Doc Generator is a powerful Dify plugin that converts Markdown content into professionally formatted Word documents (.docx). The plugin's standout feature is its intelligent chart generation system that automatically recognizes data patterns in Markdown and generates beautiful, professional charts (pie charts, bar charts, line charts) directly embedded in Word documents. Combined with a flexible template system, it enables rapid generation of data-rich, visually appealing documents.
The plugin follows a simple three-step workflow:
Markdown Content โ Template Selection โ Word Document
โ โ โ
Your content Choose style Professional output
Start with your Markdown text - this can be:
Example:
# Sales Report Q4 2024
## Monthly Sales Data
| Month | Sales | Growth |
|-------|-------|--------|
| Oct | 1000 | +10% |
| Nov | 1500 | +50% |
| Dec | 1800 | +20% |
Select a pre-built theme that matches your use case:
| Use Case | Recommended Theme | Why |
|---|---|---|
| Business reports | business | Professional, modern styling |
| Academic papers | academic | Times New Roman, double spacing |
| System alerts | default | Formal, red accent colors |
| Technical docs | minimal | Clean, minimalist design |
| Presentations | dark | Dark theme suitable for screens |
| Colorful reports | colorful | Rich color scheme |
Quick Selection:
templates: "business" # Just specify the theme name
If your document needs visualizations, enable chart generation:
enable_charts: true
chart_data: |
{
"charts": [
{
"type": "bar",
"title": "Monthly Sales Trend",
"position": "after:Monthly Sales Data",
"data": {
"Oct": 1000,
"Nov": 1500,
"Dec": 1800
}
}
]
}
The plugin returns:
Here's a complete example showing the full workflow:
# In your Dify workflow tool configuration:
# 1. Provide your Markdown content
markdown_text: |
# Annual Report 2024
## Revenue Overview
Our revenue has shown consistent growth.
| Quarter | Revenue |
|---------|---------|
| Q1 | 50000 |
| Q2 | 55000 |
| Q3 | 60000 |
| Q4 | 65000 |
# 2. Select a theme
templates: "business"
# 3. (Optional) Enable charts
enable_charts: true
chart_data: |
{
"charts": [
{
"type": "line",
"title": "Revenue Trend",
"position": "after:Revenue Overview",
"data": {
"Q1": 50000,
"Q2": 55000,
"Q3": 60000,
"Q4": 65000
}
}
]
}
# 4. (Optional) Fine-tune settings
font_size: 11
page_margins: 2.0
For basic Markdown-to-Word conversion:
markdown_texttemplates (or use default)For data-rich documents:
markdown_text with data tablesenable_charts: truechart_data with chart specificationsFor specific styling requirements:
markdown_textstyle_config for advanced customizationfont_family, font_size, etc.)Templates vs. Style Config
Chart Positioning
"after:Heading Text" to place charts after specific headingsOutput Format
.docx fileDownload the Plugin Package
.difypkg file from the releases pageInstall in Dify
.difypkg fileVerify Installation
If you want to build the plugin package yourself:
Install Dify CLI Tool
wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64
chmod +x dify-plugin-linux-amd64
Package the Plugin
./dify-plugin-linux-amd64 plugin package . -o smart_doc_generator-1.0.0.difypkg
The plugin accepts parameters that control the conversion process. Understanding these parameters helps you use the plugin effectively:
"default"
default, academic, business, minimal, dark, colorful)style_config for full control (see Template Configuration section)enable_charts (boolean, optional): Enable automatic chart generation, default false
true to enable chart insertionchart_data parameter when enabledchart_data (string, optional): Processed chart data in JSON format
{"charts": [{"type": "pie"|"bar"|"line", "title": "...", "position": "after:...", "data": {...}}]}chart_insert_width (number, optional): Chart width in centimeters, default 14.0
style_config (string, optional): Style configuration in JSON format
style_config.json.example for complete templatestyle_config.simple.json for quick startSTYLE_CONFIG_README.md for detailed documentationfont_family (string, optional): Font family, default "Microsoft YaHei"
"Microsoft YaHei", "SimSun", "Times New Roman", "Calibri", "Helvetica"font_size (number, optional): Body font size, default 12
line_spacing (number, optional): Line spacing, default 1.5
1.0, 1.5, 2.0page_margins (number, optional): Page margins in centimeters, default 2.5
paper_size (string, optional): Paper size, default "A4"
"A4", "A3", "Letter"output_file (string, optional): Output file name, default "output.docx"
Use this decision tree to determine how to use the plugin:
Start
โ
Do you need charts?
โโ No โ Use basic conversion
โ - markdown_text
โ - templates (optional)
โ - Get Word document
โ
โโ Yes โ Enable chart generation
- markdown_text
- templates (optional)
- enable_charts: true
- chart_data (required)
- Get Word document with charts
Do you need custom styling?
โโ No โ Use pre-built templates
โ - templates: "business" / "academic" / etc.
โ
โโ Yes โ Use style_config or individual parameters
- style_config (full control)
- OR font_family, font_size, etc. (quick overrides)
In a Dify workflow, simply provide Markdown text and select a template:
markdown_text: "# Title\n\nThis is the body content..."
templates: "default" # Use default theme
The tool returns two messages:
File (BLOB): Generated Word document (.docx)
files fieldapplication/vnd.openxmlformats-officedocument.wordprocessingml.documentJSON Metadata: Contains conversion result summary
{
"result": "success",
"output_file": "output.docx",
"file_size": 12345,
"settings": {
"template": "default",
"font_family": "Microsoft YaHei",
"font_size": 12,
...
}
}
Generate professional charts directly in Word documents! This plugin's most powerful feature automatically creates beautiful, publication-ready charts from your data:
Use Cases:
This plugin uses a dual-layer template architecture providing a highly customizable document styling system:
With the template system, you can:
src/templates/
โโโ themes/
โ โโโ theme_config.yaml # Theme configuration file
โโโ styles/
โโโ default.yaml # Default style template
โโโ academic.yaml # Academic style template
โโโ business.yaml # Business style template
Theme
โโโ References style template (style_template)
โโโ Defines color scheme (color_scheme)
โโโ Style overrides (overrides)
โโโ Overrides specific settings in style template
The system includes multiple predefined themes ready to use:
| Theme Name | Use Case | Characteristics |
|---|---|---|
default | System alerts, monitoring reports | Formal, professional, red color scheme |
academic | Academic papers | Times New Roman font, double spacing |
business | Business reports | Calibri font, modern business style |
minimal | Technical documents | Minimalist style, Helvetica font |
dark | Dark theme documents | Dark background, suitable for presentations |
colorful | Colorful documents | Rich and colorful color scheme |
Download the Plugin Package
.difypkg file from the releases pageInstall in Dify
.difypkg fileVerify Installation
If you want to build the plugin package yourself:
Install Dify CLI Tool
wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64
chmod +x dify-plugin-linux-amd64
Package the Plugin
./dify-plugin-linux-amd64 plugin package . -o smart_doc_generator-1.0.0.difypkg
In a Dify workflow, simply provide Markdown text and select a template:
markdown_text: "# Title\n\nThis is the body content..."
templates: "default" # Use default theme
The chart generation feature allows you to automatically insert professional charts into your Word documents. Here's how it works:
enable_charts: true in your tool parameterschart_data parameterposition fieldThe chart_data parameter accepts a JSON object with the following structure:
{
"charts": [
{
"type": "pie" | "bar" | "line",
"title": "Chart Title",
"position": "after:Heading Text" | "before:Heading Text" | "after:Table Title",
"data": {
"Label1": value1,
"Label2": value2,
...
}
}
]
}
Perfect for showing proportions and percentages:
{
"type": "pie",
"title": "Market Share",
"position": "after:Market Analysis",
"data": {
"Product A": 35,
"Product B": 25,
"Product C": 40
}
}
Ideal for comparing values across categories:
{
"type": "bar",
"title": "Monthly Sales",
"position": "after:Sales Data",
"data": {
"Jan": 1000,
"Feb": 1500,
"Mar": 1200
}
}
Great for showing trends over time:
{
"type": "line",
"title": "Revenue Trend",
"position": "after:Financial Overview",
"data": {
"Q1": 50000,
"Q2": 55000,
"Q3": 60000,
"Q4": 65000
}
}
Charts can be positioned relative to document elements:
"after:Heading Text" - Inserts chart after the first occurrence of the specified heading"before:Heading Text" - Inserts chart before the specified heading"after:Table Title" - Inserts chart after a table with the specified titlemarkdown_text: |
# Sales Report Q4 2024
## Monthly Sales Data
| Month | Sales | Growth |
|-------|-------|--------|
| Oct | 1000 | +10% |
| Nov | 1500 | +50% |
| Dec | 1800 | +20% |
## Product Distribution
Our products are distributed across three main categories.
templates: "business"
enable_charts: true
chart_data: |
{
"charts": [
{
"type": "bar",
"title": "Monthly Sales Trend",
"position": "after:Monthly Sales Data",
"data": {
"Oct": 1000,
"Nov": 1500,
"Dec": 1800
}
},
{
"type": "pie",
"title": "Product Distribution",
"position": "after:Product Distribution",
"data": {
"Category A": 45,
"Category B": 30,
"Category C": 25
}
}
]
}
chart_insert_width: 14.0
markdown_text: |
# System Alert Report
## Alert Overview
This report contains system monitoring alert information.
| Alert Level | Count |
|------------|-------|
| Critical | 5 |
| Warning | 10 |
templates: "default"
add_page_numbers: true
markdown_text: |
# Research Paper Title
## Abstract
This paper presents...
## Introduction
...
templates: "academic"
font_family: "Times New Roman"
line_spacing: 2.0
markdown_text: |
# Business Report
## Executive Summary
...
templates: "business"
font_size: 11
page_margins: 2.0
paper_size: "A4"
markdown_text: |
# Annual Performance Report 2024
## Revenue Overview
Our revenue has shown consistent growth throughout the year.
| Quarter | Revenue | Profit |
|---------|---------|--------|
| Q1 | 50000 | 10000 |
| Q2 | 55000 | 12000 |
| Q3 | 60000 | 14000 |
| Q4 | 65000 | 15000 |
## Market Share Analysis
We have maintained a strong position in the market.
## Regional Performance
Performance varies across different regions.
templates: "business"
enable_charts: true
chart_data: |
{
"charts": [
{
"type": "line",
"title": "Revenue Trend 2024",
"position": "after:Revenue Overview",
"data": {
"Q1": 50000,
"Q2": 55000,
"Q3": 60000,
"Q4": 65000
}
},
{
"type": "pie",
"title": "Market Share Distribution",
"position": "after:Market Share Analysis",
"data": {
"Our Company": 35,
"Competitor A": 25,
"Competitor B": 20,
"Others": 20
}
},
{
"type": "bar",
"title": "Regional Performance",
"position": "after:Regional Performance",
"data": {
"North": 30000,
"South": 25000,
"East": 35000,
"West": 20000
}
}
]
}
chart_insert_width: 15.0
Theme configuration is located in src/templates/themes/theme_config.yaml:
themes:
default:
name: "Default Theme"
description: "Formal theme suitable for system alerts and monitoring reports"
style_template: "default.yaml" # Referenced style template
color_scheme:
primary: "#d32f2f" # Primary color
secondary: "#ff9800" # Secondary color
accent: "#2196f3" # Accent color
background: "#ffffff" # Background color
text: "#333333" # Text color
border: "#424242" # Border color
# Custom style overrides
overrides:
fonts:
body:
name: "Microsoft YaHei"
size: 11
headings:
h1:
color: "#1a1a1a"
border_color: "#d32f2f"
table:
header_background: "#f44336"
header_font_color: "#ffffff"
Style templates are located in the src/templates/styles/ directory:
# Page settings
page:
width: 21.0 # cm
height: 29.7 # cm
margin_top: 2.5 # cm
margin_bottom: 2.5
margin_left: 3.0
margin_right: 2.5
orientation: "portrait"
# Font settings
fonts:
body:
name: "SimSun"
size: 14
color: "#000000"
heading:
name: "SimSun"
size: 16
bold: true
# Paragraph settings
paragraph:
line_spacing: 28 # 28pt fixed line spacing
space_before: 0
space_after: 0
alignment: "left"
# Heading styles
headings:
h1:
font_size: 22
font_name: "SimSun"
alignment: "center"
line_spacing: 1.25
h2:
font_size: 16
font_name: "SimHei"
bold: true
# Table styles
table:
border_width: 1.0
border_color: "#424242"
header_background: "#f44336"
header_font_color: "#ffffff"
alternate_row_color: "#fff3e0"
# Code block styles
code_block:
background_color: "#f5f5f5"
border_color: "#d32f2f"
font_family: "Consolas"
font_size: 9
src/templates/themes/theme_config.yaml:themes:
my_custom_theme:
name: "My Custom Theme"
description: "Theme suitable for my business scenario"
style_template: "default.yaml" # Can reuse existing style template
color_scheme:
primary: "#0066cc"
secondary: "#666666"
# ...
overrides:
fonts:
body:
name: "Microsoft YaHei"
size: 12
# Other override settings...
Create New Style Template (optional): If you need a completely new style configuration, create a new YAML file in the src/templates/styles/ directory
Use New Theme: Specify the theme name when calling the tool:
templates: "my_custom_theme"
files array, ensure your environment uses a plugin version that supports file BLOB returns (this project already supports it)#d32f2f)This plugin processes all data locally and does not collect or transmit any user data. For detailed privacy information, please see PRIVACY.md.
requirements.txt
dify_plugin>0.3.0matplotlib==3.8.3numpyPillowmarkdownpython-docxPyYAML.env.example to .env and fill in necessary configuration values (Dify server remote installation URL and key)pip install -r requirements.txtpython -m mainContributions are welcome! Please feel free to submit Issues and Pull Requests to improve the template system and functionality.
[Specify your license here]
For issues, questions, or feature requests, please open an issue on the GitHub repository.