Skip to content

Commit e9babb6

Browse files
authored
Merge pull request #1 from chrishanzlik/develop
First release version
2 parents 4adb0c4 + 8cb3ddc commit e9babb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+374
-157
lines changed

README.md

Lines changed: 61 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
![logo](assets/logo.jpg)
22

3-
The ZPLForge library is aimed at people who do not want to deal directly with ZPL or read the
3+
| Package | Target framework | NuGet | CI Build |
4+
| ----------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
5+
| **ZPLForge** | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/ZPLForge.svg)](https://www.nuget.org/packages/ZPLForge/) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) |
6+
| **ZPLForge.XmlSerialization** | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/v/ZPLForge.XmlSerialization.svg)](https://www.nuget.org/packages/ZPLForge.XmlSerialization/) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) |
7+
8+
9+
##### What is ZPLForge?
10+
11+
The ZPLForge library for people who do not want to deal directly with **ZPL II** or read the
412
documentation for hours. ZPLForge creates ZPL code in no time with special builders that
5-
guide user in easy steps.
13+
guides the user in easy steps.
614
Another advantage is the XML serialization which comes with the
715
*ZPLForge.XmlSerialization* package. With this, the label is saved in XML format
816
in a file or string that is easy to read and adaptable to third parties.
917

1018
##### What this library is not
1119

12-
This library is not about talking to printers. Not even
13-
for generating GRF from bitmaps. The goal of this is to stay lightweight and
14-
free of dependencies.
15-
16-
#### Package infos
20+
This library is not intended to communicate with any kind of devices. Converting bitmaps into GRF
21+
is also not part of ZPLForge's responsibility. The goal is to stay lightweight and free of
22+
dependencies.
1723

18-
| Package | Target framework | NuGet | CI build (master) | CI build (develop) |
19-
| ----------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
20-
| **ZPLForge** | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/vpre/ZPLForge.svg)](https://www.nuget.org/packages/ZPLForge/) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=develop)|
21-
| **ZPLForge.XmlSerialization** | .NET Standard 2.0 | [![NuGet](https://img.shields.io/nuget/vpre/ZPLForge.XmlSerialization.svg)](https://www.nuget.org/packages/ZPLForge.XmlSerialization/) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=master) | ![.NET Core](https://github.com/chrishanzlik/ZPLForge/workflows/.NET%20Core/badge.svg?branch=develop)|
22-
23-
#### Supported label content
24+
##### Which label elements are covered by ZPLForge?
2425
- Text
2526
- Ellipse
2627
- Rectangle
@@ -30,11 +31,14 @@ free of dependencies.
3031
- Image
3132
- Diagonal Line
3233

34+
*More barcode types will be added in future versions.*
35+
3336
## Label builder
34-
Using the `LabelBuilder` is recommended, because all required properties on the labels (and its content) will be set. Additionally this brings some validation.
37+
Using the `LabelBuilder` is recommended way to build labels in ZPLForge, because all required properties
38+
on the label (including the childs) will be covered. Additionally this brings some validation.
3539

3640
### Example
37-
This example is printed on a adhesive label with a total width of 60 mm on a ZD420
41+
This example is printed on a continuous media with a total width of 60 mm on a Zebra ZD420
3842
printer. This printer prints with a resolution of 203 dpi, so I calculated the total width in dots as
3943
follows:
4044
(60 mm / 25.4) * 203 dpi = 480 dots
@@ -43,45 +47,46 @@ follows:
4347

4448
``` csharp
4549
Label priceLabel = LabelBuilder
46-
.FromWebSensingMedia(480, PrintMode.TearOff, MediaType.ThermalTransfer)
50+
.FromCuttedContinuousMedia(480, 200, 0, MediaType.ThermalTransfer)
4751
.SetQuantity(1)
52+
.AdjustDarknessLevel(+12)
4853
.AddText(txt => txt
49-
.At(15, 30)
50-
.SetContent("Sweet Blue Shoes")
51-
.SetFont(Font.Default, 25))
54+
.At(15, 30)
55+
.SetContent("Sweet Blue Shoes")
56+
.SetFont(Font.Default, 25))
5257
.AddText(txt => txt
53-
.At(15, 60)
54-
.SetContent("The Shoe Manufcaturers")
55-
.SetFont(Font.Default, 20))
58+
.At(15, 60)
59+
.SetContent("The Shoe Manufcaturers")
60+
.SetFont(Font.Default, 20))
5661
.AddSymbol(sym => sym
57-
.At(215, 60)
58-
.SetSymbol(SymbolKind.TradeMark, 10, 10))
62+
.At(220, 60)
63+
.SetSymbol(SymbolKind.TradeMark, 10, 10))
5964
.AddCode128Barcode(c128 => c128
60-
.At(100, 105)
61-
.SetHeight(50)
62-
.SetContent("123456789"))
63-
.AddRectangle(circle => circle
64-
.At(310, 20)
65-
.SetDimensions(165, 60)
66-
.SetBorder(LabelColor.Black, 60))
65+
.At(100, 105)
66+
.SetHeight(50)
67+
.SetContent("123456789"))
68+
.AddRectangle(rect => rect
69+
.At(310, 20)
70+
.SetDimensions(165, 60)
71+
.SetBorder(LabelColor.Black, 60))
6772
.AddText(txt => txt
68-
.At(310, 35)
69-
.ApplyBlockMode(170, 1, BlockAlignment.Center)
70-
.SetContent("$ 49.99")
71-
.SetFont(Font.S, 20)
72-
.InvertColors())
73+
.At(310, 35)
74+
.ApplyBlockMode(170, 1, BlockAlignment.Center)
75+
.SetContent("$ 49.99")
76+
.SetFont(Font.S, 20)
77+
.InvertColors())
7378
.AddRectangle(rect => rect
74-
.At(5, 20)
75-
.SetDimensions(470, 170)
76-
.SetBorder(LabelColor.Black, 1))
79+
.At(5, 20)
80+
.SetDimensions(470, 170)
81+
.SetBorder(LabelColor.Black, 1))
7782
.Build();
7883

7984
string zpl = priceLabel.ToString();
8085
```
8186

8287
ZPL string generated by the builder above:
8388
``` zpl
84-
^XA^MNY,0^PW480^MMT^MTT^PQ1,0,0,N,Y^CI28^PR2,6,2^FO15,30,0^FDSweet Blue Shoes^A0,N,25,13^FS^FO15,60,0^FDThe Shoe Manufcaturers^A0,N,20,11^FS^FO215,60,0^GSN,10,10^FDC^FS^FO100,105,0^BY2,3.0,10^BCN,50,Y,N,N^FD123456789^FS^FO310,20,0^GB165,60,60,B,0^FS^FO310,35,0^FR^FD$ 49.99^AS,N,20,11^FB170,1,0,C^FS^FO5,20,0^GB470,170,1,B,0^FS^XZ
89+
^XA^LL200^MNN,0^PW480^MMC^MD12^MTT^PQ1,0,0,N,Y^CI28^PR2,6,2^FO15,30,0^FDSweet Blue Shoes^A0I,25,^FS^FO15,60,0^FDThe Shoe Manufcaturers^A0N,20,^FS^FO220,60,0^GSN,10,10^FDC^FS^FO100,105,0^BY2,3.0,10^BCN,50,Y,N,N^FD123456789^FS^FO310,20,0^GB165,60,60,B,0^FS^FO310,35,0^FR^FD$ 49.99^ASN,20,^FB170,1,0,C^FS^FO5,20,0^GB470,170,1,B,0^FS^XZ
8590
```
8691

8792
The printed label:
@@ -90,21 +95,21 @@ The printed label:
9095

9196
### Factory methods
9297

93-
Depending on the label which is inserted, choose one of the factory methods below to create a `LabelBuilder` instance.
98+
Depending on the medium what is inserted into the printer, choose one of the factory methods below to create a `LabelBuilder` instance:
9499

95100
``` csharp
96101
LabelBuilder.FromWebSensingMedia(int printWidth, PrintMode? printMode = null, MediaType? mediaType = null);
97102

98103
LabelBuilder.FromContinuousMedia(int printWidth, int labelLength, PrintMode? printMode = null, MediaType? mediaType = null);
99104

100-
LabelBuilder.FromCuttedContinuousMedia(int printWidth, int labelLength, MediaType? mediaType = null);
105+
LabelBuilder.FromCuttedContinuousMedia(int printWidth, int labelLength, int groupCutCount = 0, MediaType? mediaType = null);
101106

102107
LabelBuilder.FromBlackMarkSensingMedia(int printWidth, int blackMarkOffset, PrintMode? printMode = null, MediaType? mediaType = null);
103108
```
104109

105110
### Builder Extensibility
106111

107-
All builders can be extended with normal C# extension methods:
112+
All builders are extendable by common C# extension methods:
108113

109114
``` csharp
110115
public static class BuilderExtensions
@@ -130,13 +135,16 @@ This would make it possible to create your own builders.
130135
Label priceLabel = new Label {
131136
Quantity = 1,
132137
PrintWidth = 480,
138+
MediaTracking = MediaTracking.Continuous,
139+
MediaType = MediaType.ThermalTransfer,
140+
PrintMode = PrintMode.Cutter,
141+
MediaDarknessLevel = 12,
133142
Content = {
134143
new TextElement {
135144
PositionX = 15,
136145
PositionY = 15,
137146
Content = "Sweet Blue Shoes",
138-
CharHeight = 25,
139-
CharWidth = (int)(25 / 1.8)
147+
CharHeight = 25
140148
},
141149
new BarcodeElement {
142150
BarcodeType = BarcodeType.Code128
@@ -165,18 +173,18 @@ This will output the `Label` and its content in easy to read (and editable) XML
165173

166174
``` xml
167175
<?xml version="1.0"?>
168-
<Label version="0.1.0-beta">
169-
<MediaTracking>WebSensing</MediaTracking>
176+
<Label version="1.0.0">
177+
<MediaTracking>Continuous</MediaTracking>
170178
<PrintWidth>480</PrintWidth>
171-
<PrintMode>TearOff</PrintMode>
179+
<PrintMode>Cutter</PrintMode>
172180
<MediaType>ThermalTransfer</MediaType>
181+
<MediaDarknessLevel>12</MediaDarknessLevel>
173182
<Content>
174183
<Text>
175184
<PositionX>15</PositionX>
176185
<PositionY>30</PositionY>
177186
<Content>Sweet Blue Shoes</Content>
178187
<CharHeight>25</CharHeight>
179-
<CharWidth>13</CharWidth>
180188
</Text>
181189
<Symbol>
182190
<PositionX>215</PositionX>
@@ -196,16 +204,17 @@ This will output the `Label` and its content in easy to read (and editable) XML
196204
</Label>
197205
```
198206

199-
To serialize default values (disabled by default) use the `serializeDefaults`
200-
parameter on `LabelXmlSerializer`:
207+
For serializing default values (disabled by default) set the `serializeDefaults`
208+
parameter on `LabelXmlSerializer` to `true`:
201209

202210
```
203211
serializer.Serialize(fileStream, priceLabel, serializeDefaults: true);
204212
```
205213

206214
### Deserialization
207215

208-
To consume such label XML files, we use the `LabelXmlSerializer` again:
216+
The generated XML file above can be deserialized back into the `Label` object
217+
with the `LabelXmlSerializer` again:
209218

210219
``` csharp
211220
using var fileStream = File.OpenRead("priceLabel.xml");

src/ZPLForge.XmlSerialization/ElementNodeList.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Xml.Schema;
77
using System.Xml.Serialization;
88
using ZPLForge.Contracts;
9-
using ZPLForge.XmlSerialization.Helpers;
109

1110
namespace ZPLForge.XmlSerialization
1211
{

src/ZPLForge.XmlSerialization/LabelXmlNode.cs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public LabelXmlNode()
2626
OverridePauseCount = ZPLForgeDefaults.Elements.Label.OverridePauseCount;
2727
ReplicatesOfEachSerialNumber = ZPLForgeDefaults.Elements.Label.ReplicatesOfEachSerialNumber;
2828
CutOnError = ZPLForgeDefaults.Elements.Label.CutOnError;
29+
PositionX = ZPLForgeDefaults.Elements.Label.PositionX;
30+
PositionY = ZPLForgeDefaults.Elements.Label.PositionY;
2931

3032
Content = new List<ILabelContent>();
3133
}
@@ -38,16 +40,19 @@ public LabelXmlNode()
3840
public string Version { get; set; }
3941

4042
[XmlElement]
41-
public int? MediaLength { get; set; }
42-
43+
public int PositionX { get; set; }
44+
4345
[XmlElement]
44-
public MediaTracking? MediaTracking { get; set; }
46+
public int PositionY { get; set; }
47+
48+
[XmlElement]
49+
public int Quantity { get; set; }
4550

4651
[XmlElement]
4752
public int? PrintWidth { get; set; }
4853

4954
[XmlElement]
50-
public PrintMode? PrintMode { get; set; }
55+
public int? MediaLength { get; set; }
5156

5257
[XmlElement]
5358
public int BlackMarkOffset { get; set; }
@@ -56,10 +61,13 @@ public LabelXmlNode()
5661
public bool ReversePrintingColors { get; set; }
5762

5863
[XmlElement]
59-
public int Quantity { get; set; }
64+
public bool OverridePauseCount { get; set; }
6065

6166
[XmlElement]
62-
public bool OverridePauseCount { get; set; }
67+
public MediaTracking? MediaTracking { get; set; }
68+
69+
[XmlElement]
70+
public PrintMode? PrintMode { get; set; }
6371

6472
[XmlElement]
6573
public ZebraEncoding Encoding { get; set; }
@@ -100,6 +108,17 @@ public string BackfeedSpeedString
100108
[XmlElement]
101109
public MediaType? MediaType { get; set; }
102110

111+
[XmlElement]
112+
public int PauseAndCutValue { get; set; }
113+
114+
[XmlElement]
115+
public int ReplicatesOfEachSerialNumber { get; set; }
116+
117+
[XmlElement]
118+
public bool CutOnError { get; set; }
119+
120+
[XmlElement]
121+
public int? MediaDarknessLevel { get; set; }
103122

104123
[XmlIgnore]
105124
public List<ILabelContent> Content { get; set; }
@@ -115,10 +134,8 @@ public ElementNodeList ElementNodes
115134
set => Content = value.Cast<ILabelContent>().ToList();
116135
}
117136

118-
[XmlElement]
119-
public int PauseAndCutValue { get; set; }
120-
public int ReplicatesOfEachSerialNumber { get; set; }
121-
public bool CutOnError { get; set; }
137+
138+
122139

123140
[EditorBrowsable(EditorBrowsableState.Never)]
124141
public bool ShouldSerializePauseAndCutValue() =>
@@ -145,6 +162,11 @@ public bool ShouldSerializePrintMode() =>
145162
SerializeDefaults
146163
|| PrintMode.HasValue;
147164

165+
[EditorBrowsable(EditorBrowsableState.Never)]
166+
public bool ShouldSerializeMediaDarknessLevel() =>
167+
SerializeDefaults
168+
|| MediaDarknessLevel.HasValue;
169+
148170
[EditorBrowsable(EditorBrowsableState.Never)]
149171
public bool ShouldSerializeBackfeedSpeedString() =>
150172
SerializeDefaults
@@ -199,5 +221,15 @@ public bool ShouldSerializeReplicatesOfEachSerialNumber() =>
199221
public bool ShouldSerializeCutOnError() =>
200222
SerializeDefaults
201223
|| !CutOnError.Equals(ZPLForgeDefaults.Elements.Label.CutOnError);
224+
225+
[EditorBrowsable(EditorBrowsableState.Never)]
226+
public bool ShouldSerializePositionX() =>
227+
SerializeDefaults
228+
|| !PositionX.Equals(ZPLForgeDefaults.Elements.Label.PositionX);
229+
230+
[EditorBrowsable(EditorBrowsableState.Never)]
231+
public bool ShouldSerializePositionY() =>
232+
SerializeDefaults
233+
|| !PositionY.Equals(ZPLForgeDefaults.Elements.Label.PositionY);
202234
}
203235
}

src/ZPLForge.XmlSerialization/LabelXmlSerializer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.IO;
33
using System.Xml.Serialization;
44
using ZPLForge.Contracts;
5-
using ZPLForge.XmlSerialization.Helpers;
65

76
namespace ZPLForge.XmlSerialization
87
{

src/ZPLForge.XmlSerialization/Helpers/MappingTable.cs renamed to src/ZPLForge.XmlSerialization/MappingTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using ZPLForge.Contracts;
55

6-
namespace ZPLForge.XmlSerialization.Helpers
6+
namespace ZPLForge.XmlSerialization
77
{
88
internal static class MappingTable
99
{

src/ZPLForge.XmlSerialization/Helpers/SimpleObjectMapper.cs renamed to src/ZPLForge.XmlSerialization/SimpleObjectMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Linq.Expressions;
77
using System.Reflection;
88

9-
namespace ZPLForge.XmlSerialization.Helpers
9+
namespace ZPLForge.XmlSerialization
1010
{
1111
internal static class SimpleObjectMapper
1212
{

src/ZPLForge.XmlSerialization/Helpers/VersionProvider.cs renamed to src/ZPLForge.XmlSerialization/VersionProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Diagnostics;
22

3-
namespace ZPLForge.XmlSerialization.Helpers
3+
namespace ZPLForge.XmlSerialization
44
{
55
internal static class VersionProvider
66
{

src/ZPLForge.XmlSerialization/ZPLForge.XmlSerialization.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7-
<Version>1.0.0-beta</Version>
7+
<Version>1.0.0</Version>
88
<Authors>Christopher Hanzlik</Authors>
99
<Product>ZPLForge.XmlSerialization</Product>
1010
<Copyright>Copyright (c) 2020 Christopher Hanzlik</Copyright>
@@ -14,13 +14,14 @@
1414
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1515
<PackageProjectUrl>https://github.com/chrishanzlik/ZPLForge</PackageProjectUrl>
1616
<RepositoryUrl>https://github.com/chrishanzlik/ZPLForge</RepositoryUrl>
17-
<PackageTags>ZPL Label Printing Zebra Builder ZPLForge Serialization XML</PackageTags>
17+
<PackageTags>ZPL ZPL2 Label Printing Zebra Builder ZPLForge Serialization XML</PackageTags>
1818
<RepositoryType>Git</RepositoryType>
1919
<AssemblyVersion>1.0.0.0</AssemblyVersion>
2020
<FileVersion>1.0.0.0</FileVersion>
2121
<PackageIcon>icon.png</PackageIcon>
2222
<PackageLicenseFile></PackageLicenseFile>
2323
<Description>Library for serializing ZPL code</Description>
24+
<PackageReleaseNotes>First release version</PackageReleaseNotes>
2425
</PropertyGroup>
2526

2627
<ItemGroup>

0 commit comments

Comments
 (0)