Crates.io | metatron |
lib.rs | metatron |
version | 1.1.1 |
source | src |
created_at | 2024-03-19 03:36:25.622418 |
updated_at | 2024-09-14 04:25:34.291748 |
description | Metatron core library |
homepage | |
repository | https://github.com/igumnoff/metatron |
max_upload_size | |
id | 1178836 |
size | 59,583 |
Metatron library: Implementation in Rust of a report generation based on Shiva library
Cargo.toml
[dependencies]
metatron = "1.1.1"
fn main() {
let template = std::fs::read_to_string("report-template.kdl").unwrap();
let data = std::fs::read_to_string("report-data.json").unwrap();
let images = HashMap::new();
let result = Report::generate(&template, &data, &images, "pdf").unwrap();
std::fs::write("report.pdf",result).unwrap();
}
template {
title {
image src="data/logo.png" width=100 height=100
header level=1 "$P{company_name} Employee Report"
}
page_header {
text size=7 "Confidential information"
}
column_header {
column name="Name" width=30
column name="Age" width=10
column name="Salary" width=20
}
row {
value "$F(name)"
value "$F(age)"
value "$F(salary)"
}
column_footer {
value "Average:"
value "$P{average_age}"
value "$P{average_salary}"
}
page_footer {
text size=7 "Tel: +1 123 456 789"
}
summary {
paragraph {
text size=10 "Company address: $P{company_address}"
}
}
}
{
"rows": [
{
"name": "John",
"age": 25,
"salary": 50000
},
{
"name": "Jane",
"age": 30,
"salary": 60000
},
{
"name": "Jim",
"age": 35,
"salary": 70000
}
],
"params": {
"company_name": "ABCDFG Ltd",
"company_address": "1234 Elm St, Springfield, IL 62701",
"average_age": 30,
"average_salary": 60000
}
}
I would love to see contributions from the community. If you experience bugs, feel free to open an issue. If you would like to implement a new feature or bug fix, please follow the steps: