You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`BytesValue` wraps `ReadOnlyMemory<byte>` and is passed directly to `IBinaryContentParser` without encoding conversion. When only `IContentParser` is registered, binary data is decoded as UTF-8.
148
+
127
149
---
128
150
129
151
## SkiaBuilder
@@ -514,6 +536,11 @@ var obj = new ObjectValue
514
536
["zip"] ="123456"
515
537
}
516
538
};
539
+
540
+
// Binary data
541
+
varbytes=newBytesValue(binaryData); // from byte[]
542
+
varbytes=newBytesValue(readOnlyMemory); // from ReadOnlyMemory<byte>
543
+
varbytes=BytesValue.FromStream(stream); // from Stream
Copy file name to clipboardExpand all lines: docs/wiki/Element-Reference.md
+106-2Lines changed: 106 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1451,7 +1451,7 @@ Renders tabular data with configurable columns, optional header row, and support
1451
1451
1452
1452
## Content Element (Control Flow)
1453
1453
1454
-
Embeds dynamically formatted text (Markdown, HTML, etc.) from template data. The `source` text is parsed at render time into a subtree of FlexRender elements using pluggable content parsers.
1454
+
Embeds dynamically formatted content (Markdown, HTML, NDC binary data, etc.) from template data. The `source` supports multiple input types: plain text, `base64:`-encoded binary data, `file:` URIs, `text:` prefixed strings, and template variables bound to `string` or `byte[]` (`BytesValue`). The source is parsed at render time into a subtree of FlexRender elements using pluggable content parsers.
1455
1455
1456
1456
This is a **control-flow element** — like `each` and `if`, it is expanded during template processing and does not appear in the final render tree.
1457
1457
@@ -1465,15 +1465,54 @@ This is a **control-flow element** — like `each` and `if`, it is expanded duri
1465
1465
1466
1466
| Property | YAML Name | Type | Default | Valid Values | Expression | Description |
| Source | `source` | string | `""` | Any string, typically `{{variable}}` | Yes | The formatted text to parse. Usually bound to a data variable. |
1468
+
| Source | `source` | string | `""` | Any string, typically `{{variable}}` | Yes | The content to parse. Supports plain text, `base64:` binary, `file:` URIs, `text:` prefix, and `{{variable}}` expressions resolving to `string` or `BytesValue` (`byte[]`). See [Content Source Resolution](#content-source-resolution) below. |
1469
1469
| Format | `format` | string | `""` | `markdown`, `html`, or any registered parser name | Yes | The content format. Must match a registered `IContentParser.FormatName`. |
1470
+
| Options | `options` | dict? | `null` | Key-value dictionary | No | Parser-specific options (e.g., NDC `columns`, `charsets`). Passed to the content parser. |
1471
+
1472
+
### Content Source Resolution
1473
+
1474
+
The `source` property is resolved at render time through `ContentSourceResolver`, which supports multiple input types:
1475
+
1476
+
| Source Format | Example | Resolved As | Description |
| Template variable (`BytesValue`) | `source: "{{rawData}}"` | Binary (`byte[]`) | When `{{variable}}` resolves to `BytesValue` in the data context, binary data is passed directly to `IBinaryContentParser`. No string encoding overhead. |
1479
+
| `base64:` prefix | `source: "base64:SGVsbG8="` | Binary (`byte[]`) | Base64-encoded payload decoded into bytes. Useful for embedding binary data in JSON/YAML. |
1480
+
| `file:` scheme | `source: "file:receipt.bin"` | Binary (`byte[]`) | Loads content via registered resource loaders (file system, HTTP, embedded). Also supports `file:///` URIs. Throws if file not found. |
1481
+
| `text:` prefix | `source: "text:# Hello"` | Text (`string`) | Forces text interpretation, skipping file path detection. |
1482
+
| File path heuristic | `source: "receipt.md"` | Binary (`byte[]`) | If source looks like a file path (contains `/`, `\`, or a file extension), tries resource loaders first. Falls back to text if no loader matches. |
1483
+
| Plain text | `source: "**bold text**"` | Text (`string`) | Default fallback -- treated as literal text content. |
1484
+
1485
+
**Resolution order:** The resolver processes sources in the order listed above. The first matching rule wins.
1486
+
1487
+
**Binary vs Text parsers:**
1488
+
- `IContentParser`receives text (`string`) -- used by Markdown, HTML parsers
1489
+
- `IBinaryContentParser`receives binary data (`ReadOnlyMemory<byte>`) -- used by NDC parser
1490
+
- When source resolves to binary and the parser implements `IBinaryContentParser`, bytes are passed directly without encoding conversion
1491
+
- When source resolves to binary but the parser only implements `IContentParser`, bytes are decoded as UTF-8 text
1492
+
1493
+
**Data binding examples:**
1494
+
1495
+
```csharp
1496
+
// String data -- parsed as text
1497
+
var data = new ObjectValue { ["body"] = new StringValue("# Hello World") };
1498
+
1499
+
// Binary data -- passed directly to IBinaryContentParser
1500
+
var data = new ObjectValue { ["receiptData"] = new BytesValue(ndcBytes) };
1501
+
1502
+
// Binary data with MIME type
1503
+
var data = new ObjectValue { ["receiptData"] = new BytesValue(ndcBytes, "application/octet-stream") };
1504
+
1505
+
// From Stream
1506
+
var data = new ObjectValue { ["receiptData"] = BytesValue.FromStream(stream) };
The `ndc` format parses binary NDC (NCR ATM protocol) printer data streams from ATM/banking terminals. It supports both text and binary input via `IContentParser` and `IBinaryContentParser`.
1535
+
1536
+
#### Properties
1537
+
1538
+
The `content` element with `format: ndc` supports an `options` block:
1539
+
1540
+
| Option | Type | Default | Description |
1541
+
|--------|------|---------|-------------|
1542
+
| `columns` | int | 40 | Maximum characters per line (auto-wrapping) |
| `uppercase` | bool | false | Convert text to uppercase |
1561
+
1562
+
#### Example: NDC Receipt
1563
+
1564
+
```yaml
1565
+
canvas:
1566
+
fixed: width
1567
+
width: 384
1568
+
background: "#ffffff"
1569
+
1570
+
fonts:
1571
+
- "assets/fonts/JetBrainsMono-Regular.ttf"
1572
+
- "assets/fonts/JetBrainsMono-Bold.ttf"
1573
+
1574
+
layout:
1575
+
- type: content
1576
+
source: "{{receiptData}}"
1577
+
format: ndc
1578
+
options:
1579
+
columns: 40
1580
+
input_encoding: latin1
1581
+
font_family: "JetBrains Mono"
1582
+
charsets:
1583
+
"1":
1584
+
encoding: "qwerty-jcuken"
1585
+
font_style: bold
1586
+
```
1587
+
1588
+
Data (JSON with base64-encoded NDC binary):
1589
+
```json
1590
+
{
1591
+
"receiptData": "base64:G1sxfjQwHSgxHQ=="
1592
+
}
1593
+
```
1594
+
1595
+
The NDC parser produces `TextElement`, `BarcodeElement`, and `SeparatorElement` nodes with auto-calculated font sizes based on the parent element width.
Copy file name to clipboardExpand all lines: docs/wiki/Template-Syntax.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -507,7 +507,7 @@ Renders tabular data with configurable columns, optional headers, and support fo
507
507
508
508
### content
509
509
510
-
Embeds dynamically formatted text (Markdown, HTML, etc.) from template data using pluggable content parsers. Like `each` and `if`, this is a control-flow element expanded at render time.
510
+
Embeds dynamically formatted text (Markdown, HTML, NDC, etc.) from template data using pluggable content parsers. Like `each` and `if`, this is a control-flow element expanded at render time.
511
511
512
512
```yaml
513
513
- type: content
@@ -518,7 +518,8 @@ Embeds dynamically formatted text (Markdown, HTML, etc.) from template data usin
518
518
| Property | Type | Default | Description |
519
519
|----------|------|---------|-------------|
520
520
| `source` | string | `""` | The formatted text to parse. Usually bound to a `{{variable}}`. |
521
-
| `format` | string | `""` | Content format: `markdown`, `html`, or any registered parser name. |
521
+
| `format` | string | `""` | Content format: `markdown`, `html`, `ndc`, or any registered parser name. |
522
+
| `options` | dict? | `null` | Parser-specific options dictionary (used by NDC and custom parsers). |
522
523
523
524
See [[Element-Reference#content-element-control-flow]] for full details, element mapping, and examples.
0 commit comments