@pyreon/document 0.8.0 → 0.9.0
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 +68 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @pyreon/document
|
|
2
|
+
|
|
3
|
+
Universal document rendering for Pyreon. One template, every output format: HTML, PDF, DOCX, email, XLSX, Markdown, plain text, CSV, and custom formats.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @pyreon/document
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Document, Page, Heading, Text, Table, render } from '@pyreon/document'
|
|
15
|
+
|
|
16
|
+
const doc = (
|
|
17
|
+
<Document title="Report">
|
|
18
|
+
<Page>
|
|
19
|
+
<Heading>Sales Report</Heading>
|
|
20
|
+
<Text>Q4 performance summary.</Text>
|
|
21
|
+
<Table
|
|
22
|
+
columns={['Region', 'Revenue']}
|
|
23
|
+
rows={[['US', '$1M'], ['EU', '$800K']]}
|
|
24
|
+
/>
|
|
25
|
+
</Page>
|
|
26
|
+
</Document>
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
await render(doc, 'pdf') // PDF Uint8Array
|
|
30
|
+
await render(doc, 'email') // email-safe HTML string
|
|
31
|
+
await render(doc, 'md') // Markdown string
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Browser Download
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { download } from '@pyreon/document'
|
|
38
|
+
|
|
39
|
+
await download(doc, 'pdf', 'report.pdf')
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Primitives
|
|
45
|
+
|
|
46
|
+
Layout: `Document`, `Page`, `PageBreak`, `Section`, `Row`, `Column`, `Spacer`, `Divider`
|
|
47
|
+
|
|
48
|
+
Content: `Heading`, `Text`, `Image`, `Link`, `Button`, `Code`, `Quote`, `List`, `ListItem`, `Table`
|
|
49
|
+
|
|
50
|
+
### `render(doc, format, options?)`
|
|
51
|
+
|
|
52
|
+
Render a document tree to the specified format. Returns a `RenderResult` (string or `Uint8Array` depending on format).
|
|
53
|
+
|
|
54
|
+
### `download(doc, format, filename, options?)`
|
|
55
|
+
|
|
56
|
+
Browser-only. Renders and triggers a file download.
|
|
57
|
+
|
|
58
|
+
### `registerRenderer(format, renderer)` / `unregisterRenderer(format)`
|
|
59
|
+
|
|
60
|
+
Register custom output formats.
|
|
61
|
+
|
|
62
|
+
### `createDocument()`
|
|
63
|
+
|
|
64
|
+
Imperative builder API for constructing documents without JSX.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/package.json
CHANGED