https://github.com/swagfin/semanticxamlprint
An Xaml parser that translates to a windows print Drawing
https://github.com/swagfin/semanticxamlprint
generator pdf pdf-generation printing printing-engine receipt receipt-printer thermal-printer xaml-style
Last synced: 9 months ago
JSON representation
An Xaml parser that translates to a windows print Drawing
- Host: GitHub
- URL: https://github.com/swagfin/semanticxamlprint
- Owner: swagfin
- License: mit
- Created: 2023-04-02T13:56:48.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-21T15:37:15.000Z (over 2 years ago)
- Last Synced: 2024-01-21T16:39:11.265Z (over 2 years ago)
- Topics: generator, pdf, pdf-generation, printing, printing-engine, receipt, receipt-printer, thermal-printer, xaml-style
- Language: C#
- Homepage:
- Size: 392 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SemanticXamlPrint
Simple Library to help you with creating receipts using simple Xaml like syntax. This library uses System.Drawing to generate and print receipts
## Overview
* Generate a receipt i.e. Thermal 80mm receipt or A4 receipt
* Uses Xaml like Syntax to generate a receipt template
## Install
*NuGet Package*
```
Install-Package SemanticXamlPrint
```
https://nuget.org/packages/SemanticXamlPrint
## Usage Example
```cs
class Program
{
static void Main(string[] args)
{
//Get Template Contents
byte[] xamlFileBytes = File.ReadAllBytes("custom.grid.template");
//Use SemanticXamlPrint Parser
IXamlComponent xamlComponent = DefaultXamlParser.Parse(xamlFileBytes);
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += (obj, eventAgs) =>
{
//Use SemanticXamlPrint Draw Extension
eventAgs.DrawXamlComponent(xamlComponent);
};
printDocument.Print();
Console.ReadLine();
Environment.Exit(0);
}
}
```
## Results

## File custom.grid.template
```xaml
QTY
ITEM DESC.
AMOUNT
1
Chips with Vegetable Salad at a Discounted Price
250.00
1
HEINKEN
300.00
1
PILSNER
250.00
```
## Check out more examples on the Demo Project
[SemanticXamlPrint.Demo](https://github.com/swagfin/SemanticXamlPrint/tree/master/SemanticXamlPrint.Demo)
## Supported Xaml Components
### 1. Template
```xaml
```
### 2. Data
```xaml
I like to Text Wrap
```
### 3. Image
```xaml
```
### 4. Grid + GridRow
```xaml
Column 1
Column 2
Column 3
```
### 5. DataRow + DataRowCell
```xaml
ITEM DESC.
RATE
QTY
AMOUNT
```
### 6. Line
```xaml
```
### 7. LineBreak
```xaml
```