@veztraa/report-renderer 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/fonts/fonts/inter-400.woff +0 -0
- package/dist/fonts/fonts/inter-700.woff +0 -0
- package/dist/fonts/fonts/lato-400-italic.woff +0 -0
- package/dist/fonts/fonts/lato-400.woff +0 -0
- package/dist/fonts/fonts/lato-700-italic.woff +0 -0
- package/dist/fonts/fonts/lato-700.woff +0 -0
- package/dist/fonts/fonts/merriweather-400-italic.woff +0 -0
- package/dist/fonts/fonts/merriweather-400.woff +0 -0
- package/dist/fonts/fonts/merriweather-700-italic.woff +0 -0
- package/dist/fonts/fonts/merriweather-700.woff +0 -0
- package/dist/fonts/fonts/montserrat-400-italic.woff +0 -0
- package/dist/fonts/fonts/montserrat-400.woff +0 -0
- package/dist/fonts/fonts/montserrat-700-italic.woff +0 -0
- package/dist/fonts/fonts/montserrat-700.woff +0 -0
- package/dist/fonts/fonts/nunito-400-italic.woff +0 -0
- package/dist/fonts/fonts/nunito-400.woff +0 -0
- package/dist/fonts/fonts/nunito-700-italic.woff +0 -0
- package/dist/fonts/fonts/nunito-700.woff +0 -0
- package/dist/fonts/fonts/open-sans-400-italic.woff +0 -0
- package/dist/fonts/fonts/open-sans-400.woff +0 -0
- package/dist/fonts/fonts/open-sans-700-italic.woff +0 -0
- package/dist/fonts/fonts/open-sans-700.woff +0 -0
- package/dist/fonts/fonts/playfair-400-italic.woff +0 -0
- package/dist/fonts/fonts/playfair-400.woff +0 -0
- package/dist/fonts/fonts/playfair-700-italic.woff +0 -0
- package/dist/fonts/fonts/playfair-700.woff +0 -0
- package/dist/fonts/fonts/poppins-400-italic.woff +0 -0
- package/dist/fonts/fonts/poppins-400.woff +0 -0
- package/dist/fonts/fonts/poppins-700-italic.woff +0 -0
- package/dist/fonts/fonts/poppins-700.woff +0 -0
- package/dist/fonts/fonts/raleway-400-italic.woff +0 -0
- package/dist/fonts/fonts/raleway-400.woff +0 -0
- package/dist/fonts/fonts/raleway-700-italic.woff +0 -0
- package/dist/fonts/fonts/raleway-700.woff +0 -0
- package/dist/fonts/fonts/roboto-400-italic.woff +0 -0
- package/dist/fonts/fonts/roboto-400.woff +0 -0
- package/dist/fonts/fonts/roboto-700-italic.woff +0 -0
- package/dist/fonts/fonts/roboto-700.woff +0 -0
- package/dist/fonts/fonts/source-code-pro-400.woff +0 -0
- package/dist/fonts/fonts/source-code-pro-700.woff +0 -0
- package/dist/fonts/fonts/ubuntu-400-italic.woff +0 -0
- package/dist/fonts/fonts/ubuntu-400.woff +0 -0
- package/dist/fonts/fonts/ubuntu-700-italic.woff +0 -0
- package/dist/fonts/fonts/ubuntu-700.woff +0 -0
- package/package.json +9 -5
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @veztraa/report-renderer
|
|
2
|
+
|
|
3
|
+
PDF rendering engine for ReportForge. Converts a template JSON + data object into a PDF buffer using `@react-pdf/renderer` — pure Node.js, zero Chromium, zero Python.
|
|
4
|
+
|
|
5
|
+
Works in **Node.js and the browser** from a single install. Fonts (12 families, 44 weights) are bundled inside the package and registered automatically — no `Font.register()` calls needed.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @veztraa/report-renderer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Node.js (Express, Next.js API route, CLI, etc.)
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { render } from "@veztraa/report-renderer";
|
|
19
|
+
|
|
20
|
+
const pdf = await render(template, data);
|
|
21
|
+
|
|
22
|
+
// Save to file
|
|
23
|
+
import fs from "fs";
|
|
24
|
+
fs.writeFileSync("report.pdf", pdf);
|
|
25
|
+
|
|
26
|
+
// Stream in Express
|
|
27
|
+
app.get("/report", async (req, res) => {
|
|
28
|
+
const pdf = await render(template, data);
|
|
29
|
+
res.setHeader("Content-Type", "application/pdf");
|
|
30
|
+
res.setHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
31
|
+
res.send(pdf);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Or stream directly
|
|
35
|
+
import { renderStream } from "@veztraa/report-renderer";
|
|
36
|
+
const stream = await renderStream(template, data);
|
|
37
|
+
stream.pipe(res);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Browser (React + Vite)
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { render } from "@veztraa/report-renderer";
|
|
44
|
+
|
|
45
|
+
async function downloadPdf() {
|
|
46
|
+
const pdf = await render(template, data);
|
|
47
|
+
const blob = new Blob([pdf], { type: "application/pdf" });
|
|
48
|
+
const url = URL.createObjectURL(blob);
|
|
49
|
+
window.open(url); // or trigger download
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> Vite automatically picks the browser build (via the `browser` export condition). Fonts are embedded as base64 data URIs — no network requests, works offline.
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// Render to Buffer (Node.js) or Uint8Array (browser)
|
|
59
|
+
render(template: Template, data?: Record<string, unknown>): Promise<Buffer>
|
|
60
|
+
|
|
61
|
+
// Render to readable stream (Node.js only)
|
|
62
|
+
renderStream(template: Template, data?: Record<string, unknown>): Promise<NodeJS.ReadableStream>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Bundled Fonts
|
|
66
|
+
|
|
67
|
+
All fonts are pre-registered and available in templates via `style.fontFamily`:
|
|
68
|
+
|
|
69
|
+
| Family | Weights |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Roboto | 400, 700, italic |
|
|
72
|
+
| Open Sans | 400, 700, italic |
|
|
73
|
+
| Lato | 400, 700, italic |
|
|
74
|
+
| Montserrat | 400, 700, italic |
|
|
75
|
+
| Inter | 400, 700 |
|
|
76
|
+
| Poppins | 400, 700, italic |
|
|
77
|
+
| Nunito | 400, 700, italic |
|
|
78
|
+
| Raleway | 400, 700, italic |
|
|
79
|
+
| Ubuntu | 400, 700, italic |
|
|
80
|
+
| Playfair Display | 400, 700, italic |
|
|
81
|
+
| Merriweather | 400, 700, italic |
|
|
82
|
+
| Source Code Pro | 400, 700 |
|
|
83
|
+
|
|
84
|
+
## Template Format
|
|
85
|
+
|
|
86
|
+
See [`@veztraa/report-core`](https://www.npmjs.com/package/@veztraa/report-core) for the full template schema and expression syntax.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT © [Veztraa Innovations](https://veztraa.com)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veztraa/report-renderer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "PDF rendering engine for ReportForge",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
17
|
"browser": "./dist/index.browser.js",
|
|
14
|
-
"import":
|
|
15
|
-
"types":
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"scripts": {
|