Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a034c4b
Add Field Justification (#247)
primo-ppcg May 28, 2024
642ada2
Add missing tests
primo-ppcg May 29, 2024
7961201
Rework font stack (#248)
primo-ppcg May 30, 2024
4a039ce
Implement Aztec Barcode (#249)
primo-ppcg Jun 2, 2024
cfda683
Fix PDF scaling
Joshmul1 Jun 11, 2024
556198b
Updated ZplElementDrawer to draw a label to an external SKSurface. Up…
danzk Jun 18, 2024
bda8ec5
Merge pull request #256 from danzk/develop
primo-ppcg Jun 19, 2024
b537ed5
Add ANSI Codabar Command Analyzer, Field Data and element drawers
DSpirit Jun 21, 2024
8040877
Merge branch 'develop' of https://github.com/DSpirit/BinaryKits.Zpl i…
DSpirit Jun 21, 2024
44dbec3
Merge pull request #251 from Joshmul1/fix-pdf-scale
YipingRuan Apr 12, 2025
6f47d72
Merge pull request #258 from DSpirit/develop
YipingRuan Apr 12, 2025
cc04b49
Update .gitattributes
primo-ppcg Oct 1, 2025
6bf06f5
CC and CT parsing (#289)
primo-ppcg Oct 1, 2025
83c7d18
Support ^FH within barcodes (#290)
primo-ppcg Oct 3, 2025
fae0b36
Fix Z64 compression throwing an ArgumentOutOfRangeException on net472…
danzk Oct 3, 2025
a6cbffd
Add Quality Level to DataMatrix (#268)
aRousseaux Oct 3, 2025
65846d5
Label preview support for extended ascii characters (#270)
dant02 Oct 7, 2025
a3b883b
Fix "Application" namespace clash. (#292)
danzk Oct 16, 2025
21c9750
Update to .NET 8.0 (#293)
danzk Oct 16, 2025
fb24b19
Fix rendering of ^FT Field Typeset command for default x & y values. …
danzk Oct 21, 2025
9c09dc9
Reimplement MaxiCode (#295)
primo-ppcg Oct 22, 2025
5d8326e
Cleanup (#296)
primo-ppcg Oct 24, 2025
a4a25fb
issue 276 allow non-integer inputs to FO analyzer (#277)
nholik Oct 24, 2025
e2dfc95
Implement ^BU (#299)
primo-ppcg Oct 27, 2025
cab9e95
Implement ^B9 (#300)
primo-ppcg Oct 28, 2025
155edc0
Implement ^BS (#301)
primo-ppcg Oct 29, 2025
358b6c0
Add ZPL2PDF as Alternative Project (#303)
primo-ppcg Oct 29, 2025
22bb49d
Trim full command data (#304)
primo-ppcg Oct 29, 2025
ff6b3ec
Update dependencies
primo-ppcg Oct 29, 2025
740e4ff
Update Readme (#305)
danzk Oct 29, 2025
da996ee
Bump version numbers
primo-ppcg Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# 2011
src/BinaryKits.Zpl.Label.UnitTest/ZplData/*.txt text eol=lf
* text=auto
src/BinaryKits.Zpl.Label.UnitTest/ZplData/*.txt text eol=lf
*.png binary
2 changes: 1 addition & 1 deletion .github/workflows/deploy_binarykits-zpl-viewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Build with dotnet
working-directory: ./src/BinaryKits.Zpl.Viewer.WebApi
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dotnet - test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
Expand All @@ -33,10 +33,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
Expand All @@ -33,10 +33,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,4 @@ foreach (var labelInfo in analyzeInfo.LabelInfos)
| JavaScript | [JSZPL](https://github.com/DanieLeeuwner/JSZPL) |
| .NET | [sharpzebra](https://github.com/rkone/sharpzebra) |
| .NET | [PDFtoZPL](https://github.com/sungaila/PDFtoZPL) |
| .NET | [ZPL2PDF](https://github.com/brunoleocam/ZPL2PDF) |
17 changes: 11 additions & 6 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ csharp_new_line_before_else = true
csharp_new_line_before_members_in_object_initializers = true
#require braces to be on a new line for methods, object_collection_array_initializers, control_blocks, and types (also known as "Allman" style)
csharp_new_line_before_open_brace = methods, object_collection_array_initializers, control_blocks, types
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion

#Formatting - organize using options

Expand Down Expand Up @@ -81,15 +83,16 @@ dotnet_style_predefined_type_for_member_access = true:suggestion

#prefer objects to be initialized using object initializers when possible
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_collection_expression = when_types_exactly_match

#Style - implicit and explicit types

#prefer var over explicit type in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_elsewhere = false:warning
#prefer var is used to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_for_built_in_types = false:warning
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_when_type_is_apparent = false:warning

#Style - language keyword and framework type options

Expand All @@ -104,7 +107,7 @@ dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggest
#Style - Modifier preferences

#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,override,readonly,static,abstract:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,override,static,abstract,readonly:suggestion

#Style - Pattern matching

Expand All @@ -113,9 +116,11 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

#Style - qualification options

#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer fields to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = true:suggestion
#prefer methods to be prefaced with this. in C# or Me. in Visual Basic
dotnet_style_qualification_for_method = true:suggestion
#prefer properties to be prefaced with this. in C# or Me. in Visual Basic
dotnet_style_qualification_for_property = true:suggestion

csharp_style_prefer_primary_constructors = false:suggestion
40 changes: 36 additions & 4 deletions src/BinaryKits.Zpl.Label.UnitTest/BarcodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Barcode39()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,100\n^BY2,3\n^B3N,N,100,Y,N\n^FD123ABC^FS\n^XZ", output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,100\n^BY2,3\n^B3N,N,100,Y,N\n^FD123ABC^FS\n^XZ", output);
}

[TestMethod]
Expand All @@ -37,7 +37,7 @@ public void Barcode93()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BAN,100,Y,N,N\n^FD123ABC^FS\n^XZ", output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BAN,100,Y,N,N\n^FD123ABC^FS\n^XZ", output);
}

[TestMethod]
Expand All @@ -53,7 +53,7 @@ public void Barcode128()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BCN,100,Y,N\n^FD123ABC^FS\n^XZ", output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BCN,100,Y,N\n^FD123ABC^FS\n^XZ", output);
}

[TestMethod]
Expand All @@ -69,7 +69,39 @@ public void BarcodeEan13()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BEN,100,Y,N\n^FD123456^FS\n^XZ", output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BEN,100,Y,N\n^FD123456^FS\n^XZ", output);
}

[TestMethod]
public void DataMatrixDefault()
{
var elements = new List<ZplElementBase>
{
new ZplDataMatrix("123ABC", 100, 300)
};

var renderEngine = new ZplEngine(elements);
var output = renderEngine.ToZplString(new ZplRenderOptions { AddEmptyLineBeforeElementStart = true });

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BXN,100,0\n^FD123ABC^FS\n^XZ", output);
}

[TestMethod]
public void DataMatrix200()
{
var elements = new List<ZplElementBase>
{
new ZplDataMatrix("123ABC", 100, 300, qualityLevel: QualityLevel.ECC200)
};

var renderEngine = new ZplEngine(elements);
var output = renderEngine.ToZplString(new ZplRenderOptions { AddEmptyLineBeforeElementStart = true });

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BXN,100,200\n^FD123ABC^FS\n^XZ", output);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<TargetFramework Condition="$([MSBuild]::IsOSPlatform('Linux'))">net8.0</TargetFramework>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net472;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.1" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -27,6 +23,9 @@
<None Update="ZplData\DownloadGraphicsB64.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ZplData\DownloadGraphicsZ64_net472.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ZplData\DownloadGraphicsZ64.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
5 changes: 5 additions & 0 deletions src/BinaryKits.Zpl.Label.UnitTest/DownloadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void DownloadGraphicsACS()
[TestMethod]
[DeploymentItem(@"ZplData/Zpl.png")]
[DeploymentItem(@"ZplData/DownloadGraphicsZ64.txt")]
[DeploymentItem(@"ZplData/DownloadGraphicsZ64_net472.txt")]
public void DownloadGraphicsZ64()
{
var imageData = File.ReadAllBytes("Zpl.png");
Expand All @@ -63,7 +64,11 @@ public void DownloadGraphicsZ64()
Debug.WriteLine(output);
Assert.IsNotNull(output);

#if NET5_0_OR_GREATER
var zplData = File.ReadAllText("DownloadGraphicsZ64.txt");
#else
var zplData = File.ReadAllText("DownloadGraphicsZ64_net472.txt");
#endif
Assert.AreEqual(zplData, output);
}
[TestMethod]
Expand Down
42 changes: 38 additions & 4 deletions src/BinaryKits.Zpl.Label.UnitTest/EngineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void ChangeDPI()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n^FO591,1034\n^GB147,147,7,B,0^FS\n^XZ", output);
Assert.AreEqual("^XA\n^LH0,0\n^FO591,1034\n^GB147,147,7,B,0^FS\n^XZ", output);
}

[TestMethod]
Expand Down Expand Up @@ -102,9 +102,9 @@ public void TextFieldVariations()

var elements = new List<ZplElementBase>();
//Specail character is repalced with space
elements.Add(new ZplTextField(sampleText, 10, 10, font, useHexadecimalIndicator: false));
elements.Add(new ZplTextField(sampleText, 10, 10, font, hexadecimalIndicator: null));
//Specail character is using Hex value ^FH
elements.Add(new ZplTextField(sampleText, 10, 50, font, useHexadecimalIndicator: true));
elements.Add(new ZplTextField(sampleText, 10, 50, font, hexadecimalIndicator: '_'));
//Only the first line is displayed
elements.Add(new ZplSingleLineFieldBlock(sampleText, 10, 150, 500, font));
//Max 2 lines, text exceeding the maximum number of lines overwrites the last line.
Expand Down Expand Up @@ -132,7 +132,41 @@ public void WithoutAutoElements()

Debug.WriteLine(output);
Assert.IsNotNull(output);
Assert.AreEqual("^CI28\n^FX\n//A important field\n^A0N,30,30\n^FO50,100\n^FH^FDPure element zpl only^FS", output);
Assert.AreEqual("^FX\n//A important field\n^A0N,30,30\n^FO50,100\n^FDPure element zpl only^FS", output);
}

[TestMethod]
public void ChangeInternationalFont()
{
var elements = new List<ZplElementBase>() {
new ZplChangeInternationalFont(InternationalFont.ZCP1252),
new ZplTextField("Straße", 10, 10, ZplConstants.Font.Default, hexadecimalIndicator: '_'),
};

var renderEngine = new ZplEngine(elements);
var output = renderEngine.ToZplString(new ZplRenderOptions());

Debug.WriteLine(output);
Assert.IsNotNull(output);
//TODO: escape non-ascii characters according to current charset if hexIndicator is given
Assert.AreEqual("^XA\n^LH0,0\n^CI27\n^A0N,30,30\n^FO10,10\n^FH^FDStraße^FS\n^XZ", output);
}

[TestMethod]
public void FieldTypesetDefaultPosition()
{
var elements = new List<ZplElementBase>() {
new ZplTextField("ACME ", 10, 200, new ZplFont(30, 20, "0"), bottomToTop: true),
new ZplTextField("Summer ", 0, 0, new ZplFont(30, 20, "0"), bottomToTop: true, useDefaultPosition: true),
new ZplTextField("Clearance ", 0, 0, new ZplFont(60, 50, "0"), bottomToTop: true, useDefaultPosition: true),
new ZplTextField("Sale ", 0, 0, new ZplFont(120, 100, "0"), bottomToTop: true, useDefaultPosition: true)
};

var renderEngine = new ZplEngine(elements);
var output = renderEngine.ToZplString(new ZplRenderOptions());

Debug.WriteLine(output);
Assert.AreEqual("^XA\n^LH0,0\n^A0N,20,30\n^FT10,200\n^FDACME ^FS\n^A0N,20,30\n^FT\n^FDSummer ^FS\n^A0N,50,60\n^FT\n^FDClearance ^FS\n^A0N,100,120\n^FT\n^FDSale ^FS\n^XZ", output);
}
}
}
6 changes: 3 additions & 3 deletions src/BinaryKits.Zpl.Label.UnitTest/FieldNumberTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public void SingleElement()
var output = new ZplFieldNumber(100, textField).ToZplString();

Assert.IsNotNull(output);
Assert.AreEqual("^A0N,30,30\n^FO50,100\n^FH\n^FN100^FS", output);
Assert.AreEqual("^A0N,30,30\n^FO50,100\n^FD^FS\n^FN100^FS", output);
}

[TestMethod]
public void WrongTypeElement()
{
var data = new ZplReferenceGrid();
Assert.ThrowsException<ArgumentException>(() => new ZplFieldNumber(100, data).ToZplString());
Assert.Throws<ArgumentException>(() => new ZplFieldNumber(100, data).ToZplString());
}
}
}
}
20 changes: 10 additions & 10 deletions src/BinaryKits.Zpl.Label.UnitTest/ZebraZ64CompressionHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ namespace BinaryKits.Zpl.Label.UnitTest
[TestClass]
public class ZebraZ64CompressionHelperTest
{
[TestMethod]
public void CompressUncompress_Flow_Successful()
{
var originalData = "FFFFFFFFFFFFFFFFFFFF8000FFFF0000FFFF00018000FFFF0000FFFF00018000FFFF0000FFFF0001FFFF0000FFFF0000FFFFFFFF0000FFFF0000FFFFFFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFF";

string compressed = ZebraZ64CompressionHelper.Compress(originalData);
string uncompressed = ZebraZ64CompressionHelper.Uncompress(compressed).ToHexFromBytes();
Assert.AreEqual(originalData, uncompressed);
}
#if NET5_0_OR_GREATER
[TestMethod]
public void Compress_ValidData1_Successful()
{
Expand All @@ -19,16 +29,6 @@ public void Compress_ValidData1_Successful()
//^XGR:SAMPLE.GRF,1,1^FS
//^XZ
}
[TestMethod]
public void CompressUncompress_Flow_Successful()
{
var originalData = "FFFFFFFFFFFFFFFFFFFF8000FFFF0000FFFF00018000FFFF0000FFFF00018000FFFF0000FFFF0001FFFF0000FFFF0000FFFFFFFF0000FFFF0000FFFFFFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFF";

string compressed = ZebraZ64CompressionHelper.Compress(originalData);
string uncompressed = ZebraZ64CompressionHelper.Uncompress(compressed).ToHexFromBytes();
Assert.AreEqual(originalData, uncompressed);
}
#if NET5_0_OR_GREATER
[TestMethod]
public void DeflateNetStandardSameAsNetCore_Optimal_Successful()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
^XA
^LH0,0
^CI28

^FO0,0
^GB100,100,4,B,0^FS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
^XA
^LH0,0
^CI28

^FO0,0
^GB100,100,4,B,0^FS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
^XA
^LH0,0
^CI28

^FO0,0
^GB100,100,4,B,0^FS
Expand Down
Loading
Loading