Skip to content

Commit 8cb3ddc

Browse files
committed
Cut in groups
1 parent 6ee4f51 commit 8cb3ddc

File tree

6 files changed

+79
-33
lines changed

6 files changed

+79
-33
lines changed

README.md

Lines changed: 28 additions & 23 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 II** 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.
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.
1523

16-
#### Package infos
17-
18-
| Package | Target framework | NuGet | CI build (master) | CI build (develop) |
19-
| ----------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
20-
| **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) | ![.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/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) | ![.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 label (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,7 +47,7 @@ follows:
4347

4448
``` csharp
4549
Label priceLabel = LabelBuilder
46-
.FromCuttedContinuousMedia(480, 200, MediaType.ThermalTransfer)
50+
.FromCuttedContinuousMedia(480, 200, 0, MediaType.ThermalTransfer)
4751
.SetQuantity(1)
4852
.AdjustDarknessLevel(+12)
4953
.AddText(txt => txt
@@ -91,21 +95,21 @@ The printed label:
9195

9296
### Factory methods
9397

94-
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:
9599

96100
``` csharp
97101
LabelBuilder.FromWebSensingMedia(int printWidth, PrintMode? printMode = null, MediaType? mediaType = null);
98102

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

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

103107
LabelBuilder.FromBlackMarkSensingMedia(int printWidth, int blackMarkOffset, PrintMode? printMode = null, MediaType? mediaType = null);
104108
```
105109

106110
### Builder Extensibility
107111

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

110114
``` csharp
111115
public static class BuilderExtensions
@@ -169,7 +173,7 @@ This will output the `Label` and its content in easy to read (and editable) XML
169173

170174
``` xml
171175
<?xml version="1.0"?>
172-
<Label version="0.1.0-beta">
176+
<Label version="1.0.0">
173177
<MediaTracking>Continuous</MediaTracking>
174178
<PrintWidth>480</PrintWidth>
175179
<PrintMode>Cutter</PrintMode>
@@ -200,16 +204,17 @@ This will output the `Label` and its content in easy to read (and editable) XML
200204
</Label>
201205
```
202206

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

206210
```
207211
serializer.Serialize(fileStream, priceLabel, serializeDefaults: true);
208212
```
209213

210214
### Deserialization
211215

212-
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:
213218

214219
``` csharp
215220
using var fileStream = File.OpenRead("priceLabel.xml");

src/ZPLForge.XmlSerialization/ZPLForge.XmlSerialization.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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>

src/ZPLForge/Builders/LabelBuilder.Factories.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,59 @@ namespace ZPLForge.Builders
55
{
66
public partial class LabelBuilder
77
{
8+
/// <summary>
9+
/// Builds a <see cref="Label" /> from a continous media source.
10+
/// If the <see cref="PrintMode"/> or <see cref="MediaType"/> parameter remains null, the related ZPL commands will be omitted.
11+
/// </summary>
12+
/// <param name="printWidth">Print width of the label</param>
13+
/// <param name="labelLength">Total length of a single label</param>
14+
/// <param name="printMode">How the printer behaves after a label or labelgroup was printed</param>
15+
/// <param name="mediaType">Type of the printed medium</param>
16+
/// <returns>Returns a fresh <see cref="LabelBuilder" /> instance.</returns>
817
public static LabelBuilder FromContinuousMedia(int printWidth, int labelLength, PrintMode? printMode = null, MediaType? mediaType = null)
918
{
10-
var preset = new ContinuousPreset(printWidth, labelLength, printMode, mediaType);
19+
var preset = new ContinuousPreset(printWidth, labelLength, printMode, 0, mediaType);
1120
return new LabelBuilder(preset);
1221
}
1322

14-
public static LabelBuilder FromCuttedContinuousMedia(int printWidth, int labelLength, MediaType? mediaType = null)
23+
/// <summary>
24+
/// Builds a <see cref="Label" /> from a continous media source with cutter enabled.
25+
/// If the <see cref="MediaType"/> parameter remains null, the related ZPL command will be omitted.
26+
/// </summary>
27+
/// <param name="printWidth">Print width of the label</param>
28+
/// <param name="labelLength">Total length of a single label</param>
29+
/// <param name="groupCutCount">Print n labels and then enable the cutter.</param>
30+
/// <param name="mediaType">Type of the printed medium</param>
31+
/// <returns>Returns a fresh <see cref="LabelBuilder" /> instance.</returns>
32+
public static LabelBuilder FromCuttedContinuousMedia(int printWidth, int labelLength, int groupCutCount = 0, MediaType? mediaType = null)
1533
{
16-
var preset = new ContinuousPreset(printWidth, labelLength, PrintMode.Cutter, mediaType);
34+
var preset = new ContinuousPreset(printWidth, labelLength, PrintMode.Cutter, groupCutCount, mediaType);
1735
return new LabelBuilder(preset);
1836
}
1937

38+
/// <summary>
39+
/// Builds a <see cref="Label" /> from a media which has a black mark on his backside.
40+
/// If the <see cref="PrintMode"/> or <see cref="MediaType"/> parameter remains null, the related ZPL commands will be omitted.
41+
/// </summary>
42+
/// <param name="printWidth">Print width of the label</param>
43+
/// <param name="blackMarkOffset"></param>
44+
/// <param name="printMode">How the printer behaves after a label or labelgroup was printed</param>
45+
/// <param name="mediaType">Type of the printed medium</param>
46+
/// <returns>Returns a fresh <see cref="LabelBuilder" /> instance.</returns>
2047
public static LabelBuilder FromBlackMarkSensingMedia(int printWidth, int blackMarkOffset, PrintMode? printMode = null, MediaType? mediaType = null)
2148
{
2249
var preset = new BlackMarkSensingPreset(printWidth, blackMarkOffset, printMode, mediaType);
2350
return new LabelBuilder(preset);
2451
}
2552

2653
/// <summary>
27-
/// Used with labels that contains gaps or holes as separators.
54+
/// Builds a <see cref="Label" /> from a web sensing media. This means labels with gaps, notches, holes, etc.
55+
/// If the <see cref="PrintMode"/> or <see cref="MediaType"/> parameter remains null, the related ZPL commands will be omitted.
2856
/// </summary>
29-
/// <param name="printWidth"></param>
30-
/// <param name="mediaType"></param>
31-
/// <returns></returns>
57+
/// <param name="printWidth">Print width of the label</param>
58+
/// <param name="printMode">How the printer behaves after a label or labelgroup was printed</param>
59+
/// <param name="mediaType">Type of the printed medium</param>
60+
/// <returns>Returns a fresh <see cref="LabelBuilder" /> instance.</returns>
3261
public static LabelBuilder FromWebSensingMedia(int printWidth, PrintMode? printMode = null, MediaType? mediaType = null)
3362
{
3463
var preset = new WebSensingPreset(printWidth, printMode, mediaType);

src/ZPLForge/Presets/ContinuousPreset.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ namespace ZPLForge.Presets
66
{
77
public class ContinuousPreset : ILabelPreset
88
{
9-
public ContinuousPreset(int printWidth, int labelLength, PrintMode? printMode = null, MediaType? mediaType = null)
9+
public ContinuousPreset(int printWidth, int labelLength, PrintMode? printMode = null, int pauseAndCutValue = 0, MediaType? mediaType = null)
1010
{
1111
PrintWidth = printWidth;
1212
LabelLength = labelLength;
1313
PrintMode = printMode;
1414
MediaType = mediaType;
15+
PauseAndCutValue = pauseAndCutValue;
16+
17+
if (pauseAndCutValue > 0)
18+
OverridePauseCount = true;
1519
}
1620

1721
public int PrintWidth { get; }
1822
public int LabelLength { get; }
1923
public MediaType? MediaType { get; }
2024
public PrintMode? PrintMode { get; }
25+
public int PauseAndCutValue { get; }
26+
public bool OverridePauseCount { get; }
2127

2228
public virtual void Apply(ILabel label)
2329
{
@@ -28,7 +34,9 @@ public virtual void Apply(ILabel label)
2834
label.MediaType = MediaType;
2935
label.MediaLength = LabelLength;
3036
label.PrintMode = PrintMode;
37+
label.PauseAndCutValue = PauseAndCutValue;
3138
label.MediaTracking = MediaTracking.Continuous;
39+
label.OverridePauseCount = OverridePauseCount;
3240
}
3341
}
3442
}

src/ZPLForge/ZPLForge.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1313
<PackageProjectUrl>https://github.com/chrishanzlik/ZPLForge</PackageProjectUrl>
1414
<RepositoryUrl>https://github.com/chrishanzlik/ZPLForge</RepositoryUrl>
15-
<PackageTags>ZPL Label Printing Zebra Builder ZPLForge Zebra-Programming-Langauge Pricetag Tags</PackageTags>
15+
<PackageTags>ZPL ZPL2 Label Printing Zebra Builder ZPLForge</PackageTags>
1616
<RepositoryType>Git</RepositoryType>
1717
<PackageIcon>icon.png</PackageIcon>
1818
<Description>Library for generating ZPL code</Description>
1919
<PackageLicenseFile></PackageLicenseFile>
20+
<PackageReleaseNotes>First release version</PackageReleaseNotes>
2021
</PropertyGroup>
2122

2223
<ItemGroup>

tests/ZPLForge.Tests/LabelTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public void LabelIsCreatedWithDefaults()
3636
Assert.Equal(ZPLForgeDefaults.Elements.Label.OverridePauseCount, sut.OverridePauseCount);
3737
Assert.Equal(ZPLForgeDefaults.Elements.Label.ReplicatesOfEachSerialNumber, sut.ReplicatesOfEachSerialNumber);
3838
Assert.Equal(ZPLForgeDefaults.Elements.Label.CutOnError, sut.CutOnError);
39+
Assert.Equal(ZPLForgeDefaults.Elements.Label.PositionX, sut.PositionX);
40+
Assert.Equal(ZPLForgeDefaults.Elements.Label.PositionY, sut.PositionY);
3941
}
4042

4143
[Fact]

0 commit comments

Comments
 (0)