Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion 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;net8.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.3.0</Version>
<Version>3.3.1</Version>
<Authors>Binary Kits Pte. Ltd.</Authors>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageTags>Zebra ZPL ZPL2 Printer Label</PackageTags>
Expand Down
17 changes: 13 additions & 4 deletions src/BinaryKits.Zpl.Label/Elements/ZplGraphicDiagonalLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace BinaryKits.Zpl.Label.Elements
{
public class ZplGraphicDiagonalLine : ZplGraphicBox
public class ZplGraphicDiagonalLine : ZplGraphicElement
{
public int Width { get; private set; }
public int Height { get; private set; }

public bool RightLeaningDiagonal { get; private set; }

public ZplGraphicDiagonalLine(
Expand All @@ -12,10 +15,16 @@ public ZplGraphicDiagonalLine(
int width,
int height,
int borderThickness = 1,
bool rightLeaningDiagonal = false,
LineColor lineColor = LineColor.Black)
: base(positionX, positionY, width, height, borderThickness, lineColor, 0)
LineColor lineColor = LineColor.Black,
bool rightLeaningDiagonal = true,
bool reversePrint = false,
bool bottomToTop = false,
bool useDefaultPosition = false)
: base(positionX, positionY, borderThickness, lineColor, reversePrint, bottomToTop, useDefaultPosition)
{
Width = width;
Height = height;

RightLeaningDiagonal = rightLeaningDiagonal;
}

Expand Down
14 changes: 11 additions & 3 deletions src/BinaryKits.Zpl.Label/Elements/ZplGraphicEllipse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

namespace BinaryKits.Zpl.Label.Elements
{
public class ZplGraphicEllipse : ZplGraphicBox
public class ZplGraphicEllipse : ZplGraphicElement
{
public int Width { get; private set; }
public int Height { get; private set; }

public ZplGraphicEllipse(
int positionX,
int positionY,
int width,
int height,
int borderThickness = 1,
LineColor lineColor = LineColor.Black)
: base(positionX, positionY, width, height, borderThickness, lineColor, 0)
LineColor lineColor = LineColor.Black,
bool reversePrint = false,
bool bottomToTop = false,
bool useDefaultPosition = false)
: base(positionX, positionY, borderThickness, lineColor, reversePrint, bottomToTop, useDefaultPosition)
{
Width = width;
Height = height;
}

///<inheritdoc/>
Expand Down
41 changes: 21 additions & 20 deletions src/BinaryKits.Zpl.Label/Elements/ZplGraphicSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,33 @@ public class ZplGraphicSymbol : ZplPositionedElementBase
public int Width { get; private set; }
public int Height { get; private set; }

public GraphicSymbolCharacter Character { get; private set; }
public GraphicSymbolCharacter? Character { get; private set; }

string CharacterLetter
public ZplGraphicSymbol(
string text,
int positionX,
int positionY,
int width,
int height,
FieldOrientation fieldOrientation = FieldOrientation.Normal,
bool bottomToTop = false,
bool useDefaultPosition = false)
: base(positionX, positionY, bottomToTop, useDefaultPosition)
{
get
GraphicSymbolCharacter? character = default;
if (!string.IsNullOrEmpty(text))
{
switch (Character)
{
case GraphicSymbolCharacter.RegisteredTradeMark:
return "A";
case GraphicSymbolCharacter.Copyright:
return "B";
case GraphicSymbolCharacter.TradeMark:
return "C";
case GraphicSymbolCharacter.UnderwritersLaboratoriesApproval:
return "D";
case GraphicSymbolCharacter.CanadianStandardsAssociationApproval:
return "E";
default:
return "";
}
character = (GraphicSymbolCharacter)text[0];
}

Character = character;
FieldOrientation = fieldOrientation;
Width = width;
Height = height;
}

public ZplGraphicSymbol(
GraphicSymbolCharacter character,
GraphicSymbolCharacter? character,
int positionX,
int positionY,
int width,
Expand All @@ -55,7 +56,7 @@ public override IEnumerable<string> Render(ZplRenderOptions context)
//^GSo,h,w
var result = new List<string>();
result.AddRange(RenderPosition(context));
result.Add($"^GS{RenderFieldOrientation(FieldOrientation)},{context.Scale(Height)},{context.Scale(Width)}^FD{CharacterLetter}^FS");
result.Add($"^GS{RenderFieldOrientation(FieldOrientation)},{context.Scale(Height)},{context.Scale(Width)}^FD{(char)Character}^FS");

return result;
}
Expand Down
10 changes: 5 additions & 5 deletions src/BinaryKits.Zpl.Label/GraphicSymbolCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ public enum GraphicSymbolCharacter
/// <summary>
/// Registered Trade Mark
/// </summary>
RegisteredTradeMark,
RegisteredTradeMark = 'A',
/// <summary>
/// Copyright
/// </summary>
Copyright,
Copyright = 'B',
/// <summary>
/// Trade Mark
/// </summary>
TradeMark,
TradeMark = 'C',
/// <summary>
/// Underwriters Laboratories Approval
/// </summary>
UnderwritersLaboratoriesApproval,
UnderwritersLaboratoriesApproval = 'D',
/// <summary>
/// Canadian Standards Association Approval
/// </summary>
CanadianStandardsAssociationApproval
CanadianStandardsAssociationApproval = 'E'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
<None Update="Labels\Test\Barcode128-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\BarcodeUpcA-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\BarcodeUpcE-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\DataMatrix-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -102,6 +108,21 @@
<None Update="Labels\Example\Example9-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\GraphicDiagonalLine-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\GraphicEllipse-54x86.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\GraphicField-54x86.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\GraphicSymbol-54x86.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\HexEscape-54x86.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Labels\Test\TextPosition4-102x152.zpl2">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
25 changes: 23 additions & 2 deletions src/BinaryKits.Zpl.Viewer.WebApi/Controllers/ViewerController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using BinaryKits.Zpl.Viewer.ElementDrawers;
using BinaryKits.Zpl.Viewer.WebApi.Models;
using BinaryKits.Zpl.Viewer.WebApi.Properties;

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

using SkiaSharp;

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace BinaryKits.Zpl.Viewer.WebApi.Controllers
{
Expand All @@ -28,14 +35,28 @@ public ActionResult<RenderResponseDto> Render(RenderRequestDto request)
}
catch (Exception ex)
{
return this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
StringBuilder builder = new StringBuilder();
while (ex is Exception) {
builder.AppendLine(ex.Message);
builder.AppendLine(ex.StackTrace);
ex = ex.InnerException;
}

return this.StatusCode(StatusCodes.Status500InternalServerError, builder.ToString());
}
}

private ActionResult<RenderResponseDto> RenderZpl(RenderRequestDto request)
{
IPrinterStorage printerStorage = new PrinterStorage();
var drawerOptions = new DrawerOptions();

var fontManager = new FontManager();
//register default fonts
fontManager.RegisterTypeface(SKTypeface.FromStream(new MemoryStream(Resources.TeX_Gyre_Heros_Cn_Bold)));
fontManager.RegisterTypeface(SKTypeface.FromStream(new MemoryStream(Resources.DejaVu_Sans_Mono)));

var drawerOptions = new DrawerOptions(fontManager);

drawerOptions.OpaqueBackground = true; //set white background for viewer requests

//PDF mode (image mode is default)
Expand Down
Loading
Loading