Skip to content

Commit

Permalink
Merge develop branch (#232)
Browse files Browse the repository at this point in the history
* Create dotnet - test.yml

* Bump SkiaSharp from 2.88.3 to 2.88.6 in /src/BinaryKits.Zpl.Viewer

Bumps [SkiaSharp](https://github.com/mono/SkiaSharp) from 2.88.3 to 2.88.6.
- [Release notes](https://github.com/mono/SkiaSharp/releases)
- [Commits](mono/SkiaSharp@v2.88.3...v2.88.6)

---
updated-dependencies:
- dependency-name: SkiaSharp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(viewer): cannot find package vue@next (#208)

* fix(viewer): cannot find package vue@next

* Update index.html

Don't use specific versions for web dependencies.

* Enable ^FV command (needed for UPS) (#195)

* Enable ^FV command

- Based off ^FD

* ZPL Parser: Enable ignoring certain commands (#194)

* Enable ignoring certain commands

- small refactors + comments in the zpl parser

* Comment specification

* Add documentation on how to add barcode support (#198)

* Change invertdraw to skia xor blending (#193)

- Also added tests
- Refactored viewer tests

* Structure Viewer UnitTest project (merge after #193) (#199)

* Change invertdraw to skia xor blending

- Also added tests
- Refactored viewer tests

* Begin structuring viewer testing project

- readme for goals
- custom test for feature development
- zpl/png data folder copied to output
- factor out more to common

* Try to fix cannot copy data to output for linux build

* Copy data again

* Capitalization mistake

* Added: Font fallback structure for the default fonts. (#217)

* Added: Font fallback structure for the default fonts.

* Improved: DejaVu Sans Mono as first mono type
Improved: Courier New is more often available than Courier

* Added: Roboto font to Dockerfile

* Improved: Enabled antialiased text (#218)

* Improved: Barcode scaling for PDF417 and Code128 (#219)

* Improved: Code128 charset usage
Improved: PDF417 scaling
Improved: DHL uses a decimal height for PDF417
Improved: PDF417 size when no column value is given

* Improved: PDF417 uses correct vertical scaling now

* Improved: GS1 type support
Improved: Code128 invocation filtering

* Added: PDF generation (#220)

* Added: Font fallback structure for the default fonts.

* Improved: DejaVu Sans Mono as first mono type
Improved: Courier New is more often available than Courier

* Improved: Enabled antialiased text

* Improved: Code128 charset usage
Improved: PDF417 scaling
Improved: DHL uses a decimal height for PDF417
Improved: PDF417 size when no column value is given

* Added: Roboto fontface to docker image

* Improved: Added a working roboto font to the Dockerfile

* Improved: PDF417 uses correct vertical scaling now

* Added: PDF support
Added: Download buttons for ZPL, PNG and PDF
Fixed: GraphicBox radius with thicker lines
Improved: Invert/Reverse draw results when using white elements
Improved: White background for PNG requested from viewer

* Added: More real world tests
Improved: Tabs for tests and examples in webinterface

* Improved: GraphicBox can't have a border smaller than 1

* Improved: Made more ^FR blending native for performance

* Improved: GraphicBox border should not exceed half of the smallest side.
Improved: Adjusted some example sizes

* Fixed: Build issues

* Improved: More Skia blending to improve performance
Improved: Performance of GraphicBox rounding fix
Added: GraphicCircle supports reverse draw now
Improved: Overlay can handle custom label sizes better now

* Improved: Overlay requests may use wrong number formatting

* Bump Dependencies

Bump ImageSharp and SkiaSharp dependencies.

* Added: MaxiCode support (#224)

* Added: MaxiCode support

* Improved: Slight finetune on maxicode linux fix

* Patch #194 (#227)

Don't neglect to append on ignore.

* Added: Barcode93 support (#226)

* Added: Barcode93 support

* Update Code93

Update interpretation line
Add test to WebApi

* Fix vue lib URL (#228)

* Drop BarcodeLib dependency (#229)

* Drop BarcodeLib dependency

* don't inline regex

* Prepare for release

* Silence warnings

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Yiping <YipingRuan@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dmitrii Savchenkov <dmisavchenkv@gmail.com>
Co-authored-by: reportingissue <136993729+reportingissue@users.noreply.github.com>
Co-authored-by: Daniël van der Garde <12891775+daanggc@users.noreply.github.com>
Co-authored-by: Marius Starke <72494359+marius-arch@users.noreply.github.com>
Co-authored-by: Yiping <kookaburracc@msn.com>
  • Loading branch information
8 people authored Apr 26, 2024
1 parent 3f4df76 commit 5c72337
Show file tree
Hide file tree
Showing 84 changed files with 3,028 additions and 520 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/dotnet - test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: .NET

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
build-windows:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
- name: Build
working-directory: ./src
run: dotnet build --configuration Release --no-restore /p:NoWarn=1591
- name: Test
working-directory: ./src
run: dotnet test --configuration Release --no-restore --no-build --verbosity normal

build-linux:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
- name: Build
working-directory: ./src
run: dotnet build --configuration Release --no-restore /p:NoWarn=1591
- name: Test
working-directory: ./src
run: dotnet test --configuration Release --no-restore --no-build --verbosity normal


16 changes: 16 additions & 0 deletions src/BinaryKits.Zpl.Label.UnitTest/BarcodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ public void Barcode39()
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);
}

[TestMethod]
public void Barcode93()
{
var elements = new List<ZplElementBase>
{
new ZplBarcode93("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^CI28\n\n^FO100,300\n^BY2,3\n^BAN,100,Y,N,N\n^FD123ABC^FS\n^XZ", output);
}

[TestMethod]
public void Barcode128()
{
Expand Down
4 changes: 2 additions & 2 deletions src/BinaryKits.Zpl.Label/BinaryKits.Zpl.Label.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net472;netstandard2.0;net6.0</TargetFrameworks>
<Description>This package allows you to simply and reliably prepare labels complying with the Zebra programming language, using predefined class/typing. It also supports you with image conversion.</Description>
<Company>Binary Kits Pte. Ltd.</Company>
<Version>3.1.5</Version>
<Version>3.2.0</Version>
<Authors>Binary Kits Pte. Ltd.</Authors>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>Zebra ZPL ZPL2 Printer Label</PackageTags>
Expand All @@ -23,7 +23,7 @@

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp">
<Version>2.1.3</Version>
<Version>2.1.8</Version>
</PackageReference>
</ItemGroup>

Expand Down
69 changes: 69 additions & 0 deletions src/BinaryKits.Zpl.Label/Elements/ZplBarcode93.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections.Generic;

namespace BinaryKits.Zpl.Label.Elements
{
/// <summary>
/// Code 93 Barcode
/// </summary>
public class ZplBarcode93 : ZplBarcode
{
public bool CheckDigit { get; private set; }

/// <summary>
/// Code 93 Barcode
/// </summary>
/// <param name="content"></param>
/// <param name="positionX"></param>
/// <param name="positionY"></param>
/// <param name="height"></param>
/// <param name="moduleWidth"></param>
/// <param name="wideBarToNarrowBarWidthRatio"></param>
/// <param name="fieldOrientation"></param>
/// <param name="printInterpretationLine"></param>
/// <param name="printInterpretationLineAboveCode"></param>
/// <param name="bottomToTop"></param>
/// <param name="checkDigit"></param>
public ZplBarcode93(
string content,
int positionX,
int positionY,
int height = 100,
int moduleWidth = 2,
double wideBarToNarrowBarWidthRatio = 3,
FieldOrientation fieldOrientation = FieldOrientation.Normal,
bool printInterpretationLine = true,
bool printInterpretationLineAboveCode = false,
bool checkDigit = false,
bool bottomToTop = false)
: base(content,
positionX,
positionY,
height,
moduleWidth,
wideBarToNarrowBarWidthRatio,
fieldOrientation,
printInterpretationLine,
printInterpretationLineAboveCode,
bottomToTop)
{
this.CheckDigit = checkDigit;
}

///<inheritdoc/>
public override IEnumerable<string> Render(ZplRenderOptions context)
{
//TODO:Add 'mode'

//^FO100,100 ^ BY3
//^BAN,100,Y,N,N
//^FD123456 ^ FS
var result = new List<string>();
result.AddRange(RenderPosition(context));
result.Add(RenderModuleWidth());
result.Add($"^BA{RenderFieldOrientation()},{context.Scale(Height)},{RenderPrintInterpretationLine()},{RenderPrintInterpretationLineAboveCode()},{(CheckDigit ? "Y" : "N")}");
result.Add($"^FD{Content}^FS");

return result;
}
}
}
3 changes: 2 additions & 1 deletion src/BinaryKits.Zpl.Label/Elements/ZplGraphicCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public ZplGraphicCircle(
int diameter,
int borderThickness = 1,
LineColor lineColor = LineColor.Black,
bool reversePrint = false,
bool bottomToTop = false)
: base(positionX, positionY, borderThickness, lineColor, bottomToTop: bottomToTop)
: base(positionX, positionY, borderThickness, lineColor, reversePrint, bottomToTop)
{
Diameter = diameter;
}
Expand Down
85 changes: 85 additions & 0 deletions src/BinaryKits.Zpl.Label/Elements/ZplMaxiCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Collections.Generic;
using System.Text;

namespace BinaryKits.Zpl.Label.Elements
{
public class ZplMaxiCode : ZplPositionedElementBase, IFormatElement
{
public string Content { get; protected set; }

public int Mode { get; private set; }

public int Position { get; private set; }

public int Total { get; private set; }

public bool UseHexadecimalIndicator { get; protected set; }

/// <summary>
/// Zpl QrCode
/// </summary>
/// <param name="content"></param>
/// <param name="positionX"></param>
/// <param name="positionY"></param>
/// <param name="mode">2 (numeric postal code) Default, 3 (alphanumeric postal code), 4 (standard), 5 (full EEC), and 6 (reader programming)</param>
/// <param name="position">1-8, (default: 1)</param>
/// <param name="total">1-8, (default: 1)</param>
/// <param name="useHexadecimalIndicator"></param>
/// <param name="bottomToTop"></param>
public ZplMaxiCode(
string content,
int positionX,
int positionY,
int mode = 2,
int position = 1,
int total = 1,
bool useHexadecimalIndicator = false,
bool bottomToTop = false)
: base(positionX, positionY, bottomToTop)
{
Content = content;
Mode = mode;
Position = position;
Total = total;
UseHexadecimalIndicator = useHexadecimalIndicator;
}

///<inheritdoc/>
public override IEnumerable<string> Render(ZplRenderOptions context)
{
//^FO100,100
//^BD2,1,1
//^FH^FD002840100450000_5B)>_1E01_1D961Z00136071_1DUPSN_1D123X56_1D028_1D_1D001/001_1D011_1DN_1D_1DNEW YORK_1DNY_1E_04^FS
var result = new List<string>();
result.AddRange(RenderPosition(context));
result.Add($"^BD{Mode},{Position},{Total}");
result.Add(RenderFieldDataSection());

return result;
}

protected string RenderFieldDataSection()
{
var sb = new StringBuilder();
if (UseHexadecimalIndicator)
{
sb.Append("^FH");
}

if (Content != null)
{
sb.Append("^FD");
sb.Append(Content);
sb.Append("^FS");
}

return sb.ToString();
}

/// <inheritdoc />
public void SetTemplateContent(string content)
{
Content = content;
}
}
}
4 changes: 4 additions & 0 deletions src/BinaryKits.Zpl.Label/Elements/ZplPDF417.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ZplPDF417 : ZplPositionedElementBase, IFormatElement
{

public int Height { get; protected set; }
public int ModuleWidth { get; protected set; }
public string Content { get; protected set; }
public FieldOrientation FieldOrientation { get; protected set; }
public int? Columns { get; protected set; }
Expand All @@ -23,6 +24,7 @@ public class ZplPDF417 : ZplPositionedElementBase, IFormatElement
/// <param name="positionX"></param>
/// <param name="positionY"></param>
/// <param name="height"></param>
/// <param name="moduleWidth"></param>
/// <param name="columns">1-30: Number of data columns to encode. Default will auto balance 1:2 row to column</param>
/// <param name="rows">3-90. Number of data columns to encode. Default will auto balance 1:2 row to column</param>
/// <param name="compact">Truncate right row indicators and stop pattern</param>
Expand All @@ -34,6 +36,7 @@ public ZplPDF417(
int positionX,
int positionY,
int height = 8,
int moduleWidth = 2,
int? columns = null,
int? rows = null,
bool compact = false,
Expand All @@ -45,6 +48,7 @@ public ZplPDF417(
{
FieldOrientation = fieldOrientation;
Height = height;
ModuleWidth = moduleWidth;
Columns = columns;
Rows = rows;
Compact = compact;
Expand Down
2 changes: 1 addition & 1 deletion src/BinaryKits.Zpl.Labelary/BinaryKits.Zpl.Labelary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<Description>This package provides a client for the Labelary API for rendering ZPL data</Description>
<Company>Binary Kits Pte. Ltd.</Company>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<Authors>Binary Kits Pte. Ltd.</Authors>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>Zebra ZPL ZPL2 ZPLEmulator ZPLVirtualPrinter ZPLViewer Labelary</PackageTags>
Expand Down
8 changes: 5 additions & 3 deletions src/BinaryKits.Zpl.Labelary/LabelSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public double WidthInInch
return _width;
}

return Math.Round(_width / _millimeterToInch, 0);
var rounded = Math.Round(_width / _millimeterToInch, 8);
return rounded;
}
}

Expand All @@ -37,8 +38,9 @@ public double HeightInInch
{
return _height;
}

return Math.Round(_height / _millimeterToInch, 0);

var rounded = Math.Round(_height / _millimeterToInch, 8);
return rounded;
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/BinaryKits.Zpl.Labelary/LabelaryClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using System;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -42,9 +43,15 @@ public async Task<byte[]> GetPreviewAsync(
{
var dpi = printDensity.ToString().Substring(2);
var zpl = Encoding.UTF8.GetBytes(zplData);

//without setting this, a comma separator might be used for for the size numbers in the URL
var specifier = "G";
var culture = CultureInfo.CreateSpecificCulture("en-US");
var width = labelSize.WidthInInch.ToString(specifier, culture);
var height = labelSize.HeightInInch.ToString(specifier, culture);

using var byteContent = new ByteArrayContent(zpl);
using (var response = await _httpClient.PostAsync($"{_apiEndpoint}/{dpi}/labels/{labelSize.WidthInInch}x{labelSize.HeightInInch}/0/", byteContent))
using (var response = await _httpClient.PostAsync($"{_apiEndpoint}/{dpi}/labels/{width}x{height}/0/", byteContent))
{
if (!response.IsSuccessStatusCode)
{
Expand Down
4 changes: 2 additions & 2 deletions src/BinaryKits.Zpl.Protocol/BinaryKits.Zpl.Protocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net472;netstandard2.0;net6.0</TargetFrameworks>
<Description>This package contains the zebra protocol of the Zebra Programming Language. It also supports you with image conversion.</Description>
<Company>Binary Kits Pte. Ltd.</Company>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Binary Kits Pte. Ltd.</Authors>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>Zebra ZPL ZPL2 Printer Protocol</PackageTags>
Expand All @@ -23,7 +23,7 @@

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp">
<Version>1.0.4</Version>
<Version>2.1.8</Version>
</PackageReference>
</ItemGroup>

Expand Down
Loading

0 comments on commit 5c72337

Please sign in to comment.