An open API service indexing awesome lists of open source software.

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

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

![Result](https://github.com/swagfin/SemanticXamlPrint/blob/a3a0b443bc8e1c7d3eb9ee6b9e9a92643a14901d/Screenshots/sample-grid.jpg)

## 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

```