Skip to content

Repository files navigation

Reports.Web for Node.js / TypeScript

Reports.Web — Node.js / TypeScript サンプル

npm engine Live demo

Reports.Web は、ブラウザで帳票をデザインし、いろいろな言語から PDF を作る帳票ツールです。このリポジトリは、Node.js / TypeScript から使うサンプル(オンラインデモと同じソース)です。

請求書・見積書・納品書・宛名ラベル・名刺など、日本の業務帳票をそのまま作れます。帳票のレイアウトはブラウザのデザイナーで作り、アプリは値を入れて「印刷データ(PREPEJ)」を作るだけです。描画は C++ WebAssembly の帳票エンジンが行います。

デザイナー(ブラウザ) Node.js のデモ(プレビュー)
Reports.Web Designer Node.js demo

サンプルを選ぶ

# フォルダー 内容 ポート
01 01.あっという間に帳票出力 JavaScript の短いコードで、1 ページの帳票を表示・PDF 出力 http://127.0.0.1:19220/
02 02.全帳票をWebでプレビュー TypeScript と PostgreSQL で 8 種類の帳票(請求書・見積書・郵便番号 81 ページなど)を作る Web アプリ http://127.0.0.1:19221/
03 03.Web API・REST連携 02 と同じ帳票処理を Web API にし、別の利用側 Web アプリから呼ぶ http://127.0.0.1:19222/

迷ったら 01 から順にどうぞ。各フォルダーは独立していて、別々に起動・停止できます。

クイックスタート

必要なのは Docker(Docker Desktop など)だけです。Node.js や PostgreSQL をパソコンに入れる必要はありません。

git clone https://github.com/ReportsWeb/wasm-node.git
cd "wasm-node/01.あっという間に帳票出力"
docker compose up -d --build --wait --wait-timeout 180
# ブラウザで http://127.0.0.1:19220/ を開く
docker compose down --volumes   # 終わったら停止・削除

コードの要点

import { PrintData, ReportsWebEngine } from "@pao-at-office/reports-web";

const printData = new PrintData()
  .setDefinition(definition)          // ブラウザのデザイナーで作った .prepdj
  .pageStart()
  .setValue("Message", "Node.jsから、あっという間に帳票出力")
  .pageEnd();

const pdf = await new ReportsWebEngine({ url: "http://engine:3107" }).renderPdf(printData);

しくみ

Node.js アプリ ──(印刷データ PREPEJ / JSON)──▶ 帳票エンジン ghcr.io/reportsweb/engine ──▶ PDF
      ▲                                              (C++ WebAssembly、Docker)
  帳票定義 .prepdj(ブラウザのデザイナーで作成)

各サンプルの compose.yaml は、帳票エンジンのイメージを起動し、同じイメージからデザイナー・プレビュー画面のファイルを取り出して使います。

体験版と製品版

npm パッケージと帳票エンジンは体験版で、出力には赤い「SAMPLE」の印が付きます。ご購入後に納品するライセンスファイルを帳票エンジンに設定すると印が消えます(開発用パソコン 1 台につき 1 ライセンス、運用環境はランタイムライセンスフリー)。

このリポジトリのサンプルコードは MIT License です。npm パッケージと帳票エンジンには Reports.Web の使用許諾が適用されます。

ほかの言語

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

Manual/ のプログラマーズガイドは配布 ZIP 向けに書かれています。このリポジトリでは、PrintData を同梱ファイルではなく npm パッケージから読み込みます。


English

Reports.Web is a report designer and PDF engine. Design report layouts (invoices, estimates, delivery slips, address labels, business cards) in the browser, then build print data (PREPEJ JSON) from your application and render PDF with the C++ WebAssembly engine. This repository contains the Node.js / TypeScript samples — the same source as the live demo.

Quick start: install Docker, then

git clone https://github.com/ReportsWeb/wasm-node.git
cd "wasm-node/01.あっという間に帳票出力"
docker compose up -d --build --wait --wait-timeout 180   # open http://127.0.0.1:19220/

The package and the engine are trial builds; output carries a red "SAMPLE" mark until a purchased license file is configured. Sample code: MIT. Package and engine: Reports.Web license.

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

About

Reports.Web samples for Node.js / TypeScript: design reports in the browser, render PDF with the C++ WebAssembly engine (npm @pao-at-office/reports-web).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages