reports-web 1.0.0

Reports.Web for Rust: build PREPEJ print data from .prepdj report definitions and render PDF with the Reports.Web engine (C++ WebAssembly). Japanese business forms: invoices, estimates, labels. Trial build.
Documentation

reports-web

Reports.Web for Rust — 帳票定義(.prepdj)に値を入れて印刷データ(PREPEJ)を作り、Reports.Web エンジン(C++ WebAssembly)で PDF にします。請求書・見積書・納品書・宛名ラベル・名刺など、日本の業務帳票向けです。

Build print data (PREPEJ) from a report definition (.prepdj) and render it to PDF with the Reports.Web engine (C++ WebAssembly). Designed for Japanese business forms: invoices, estimates, delivery slips, address labels, business cards.

しくみ / How it works

your Rust app ──(PREPEJ JSON)──▶ Reports.Web engine (Docker: ghcr.io/reportsweb/engine) ──▶ PDF
      ▲
 report definition (.prepdj) designed in the browser designer

帳票のデザインはブラウザのデザイナーで作ります。アプリは値を入れて印刷データを作り、エンジンに送るだけです。

インストール / Install

[dependencies]
reports-web = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde_json = "1"
docker run -d -p 3107:3107 ghcr.io/reportsweb/engine:1.0.0

使い方 / Quick start

use reports_web::{PrintData, ReportsWebEngine};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let definition: serde_json::Value =
        serde_json::from_str(&std::fs::read_to_string("quick-report.prepdj")?)?;

    let mut print_data = PrintData::new();
    print_data.set_definition(&definition)?.page_start()?;
    print_data.set_value("Title", "あっという間に帳票出力")?;
    print_data.set_value("CustomerName", "株式会社パオ")?.page_end()?;

    let engine = ReportsWebEngine::new("http://127.0.0.1:3107")?;
    std::fs::write("report.pdf", engine.render_pdf(&print_data).await?)?;
    Ok(())
}

API

PrintData

メソッド / Method 内容 / Description
set_definition(&definition) 帳票定義(.prepdj の内容)を設定 / Set the report definition
page_start() / page_start_with(Some(&def)) / page_end() ページの開始と終了 / Begin and end a page
set_value(name, value) / set_value_at(name, value, index, drawing) 文字などの値 / Set a value
set_repeated_value(name, value, x, y, drawing) 繰り返し(明細行など)の値 / Repeated object value
set_image(name, source) / set_barcode(name, code) 画像・バーコード / Image and barcode
change_attributes(name, values, index) 色・位置などの属性 / Change attributes
to_value() / to_json(pretty) / save(path) 印刷データ(PREPEJ)を取り出す・保存 / Get or save the PREPEJ

ReportsWebEngine(非同期 / async, reqwest + rustls)

メソッド / Method 内容 / Description
ReportsWebEngine::new(url) / from_env() / with_timeout(url, d) from_env は REPORTS_ENGINE_URL、なければ http://127.0.0.1:3107
render_pdf(&print_data) / render_pdf_json(bytes) PDF のバイト列 / PDF bytes
health() エンジンの状態 / Engine status

エラーは EngineError(status に HTTP ステータス)で返ります。 Errors are returned as EngineError with the HTTP status.

体験版と製品版 / Trial and product

このクレートとエンジンのイメージは体験版です。出力には赤い「SAMPLE」の印が付きます。ご購入後に納品するライセンスファイルをエンジンに設定すると、印が消えます。

The crate and the engine image are trial builds: output carries a red "SAMPLE" mark. Mount the license file delivered on purchase:

docker run -d -p 3107:3107 -v /path/to/reports-web.license:/app/reports-web.license:ro ghcr.io/reportsweb/engine:1.0.0

開発用パソコン 1 台につき 1 ライセンス、運用環境はランタイムライセンスフリーです。詳しくは LICENSE.md と 使用許諾 をご覧ください。

他の言語 / Other languages

Reports.Web は同じ帳票定義と印刷データを、PHP・Java・.NET・Go・Ruby・Rust・Node.js から使えます。Pure Java・WPF 版もあります。 https://github.com/ReportsWeb


Pao@Office — https://www.pao.ac/ — info@pao.ac