diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 49878fe..6fa9129 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: attributes: label: PDFtoZPL version description: Which version of PDFtoZPL is affected? - value: 5.1.0 + value: 5.3.0 validations: required: true - type: dropdown diff --git a/Console/Console.csproj b/Console/Console.csproj index 82b89e2..e67450e 100644 --- a/Console/Console.csproj +++ b/Console/Console.csproj @@ -6,7 +6,7 @@ PDFtoZPL.Console PDFtoZPL.Console PDFtoZPL.Console.Program - 5.2.0 + 5.3.0 Debug;Release;ReleaseSigned diff --git a/PDFtoZPL/Conversion.cs b/PDFtoZPL/Conversion.cs index b283284..bf771d0 100644 --- a/PDFtoZPL/Conversion.cs +++ b/PDFtoZPL/Conversion.cs @@ -402,6 +402,14 @@ private static string ConvertBitmapImpl(SKBitmap pdfBitmap, ZplOptions zplOption if (zplOptions.PrintQuantity > 0) zpl = zpl.Replace("^XZ", $"^PQ{Math.Min(zplOptions.PrintQuantity, 99999999)}^XZ"); + // set the ^LT to shift the label up or down + if (zplOptions.LabelTop != 0 && zplOptions.LabelTop <= 120 && zplOptions.LabelTop >= -120) + zpl = zpl.Replace("^XA", $"^XA^LT{zplOptions.LabelTop}"); + + // set the ^LS to shift the label left or right + if (zplOptions.LabelShift != 0 && zplOptions.LabelShift <= 9999 && zplOptions.LabelShift >= -9999) + zpl = zpl.Replace("^XA", $"^XA^LS{zplOptions.LabelShift}").Replace("^XZ", "^LS0^XZ"); + // finally return the complete ZPL code return zpl; } diff --git a/PDFtoZPL/IZplOptions.cs b/PDFtoZPL/IZplOptions.cs index 0639ccd..5de3862 100644 --- a/PDFtoZPL/IZplOptions.cs +++ b/PDFtoZPL/IZplOptions.cs @@ -34,5 +34,15 @@ public interface IZplOptions /// Adds the ^PQ command to set the total quantity of labels to print. Accepted values are 1 to 99,999,999. Ignored if set to 0. /// uint PrintQuantity { get; init; } + + /// + /// Adds the ^LT command to move the entire label up or down from its current position (in relation to the top edge of the label). Valid values are between 120 (move label down) and -120 (move label up) dot rows. Values outside of this range are ignored and some printers might accept even fewer. + /// + sbyte LabelTop { get; init; } + + /// + /// Adds the ^LS command to move the entire label left or right from its current position. Valid values are between 9999 (move label left) and -9999 (move label right). Values outside of this range are ignored. + /// + short LabelShift { get; init; } } } \ No newline at end of file diff --git a/PDFtoZPL/PDFtoZPL.csproj b/PDFtoZPL/PDFtoZPL.csproj index 0c8ea90..152d8f1 100644 --- a/PDFtoZPL/PDFtoZPL.csproj +++ b/PDFtoZPL/PDFtoZPL.csproj @@ -12,7 +12,7 @@ - 5.2.0 + 5.3.0 David Sungaila false @@ -21,7 +21,8 @@ https://github.com/sungaila/PDFtoZPL https://raw.githubusercontent.com/sungaila/PDFtoZPL/master/Icon_128.png A .NET library to convert PDF files (and bitmaps) into Zebra Programming Language code. - - Added System.Index for single page conversion. + - Added optional parameter LabelTop. +- Added optional parameter LabelShift. PDF ZPL Zebra Bitmap Convert Conversion C# PDFium MAUI wasm WebAssembly https://github.com/sungaila/PDFtoZPL.git git diff --git a/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt index 7c067b4..4f59480 100644 --- a/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt index 7c067b4..4f59480 100644 --- a/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt index 7c067b4..4f59480 100644 --- a/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt index b6554cc..66cd457 100644 --- a/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt index b6554cc..66cd457 100644 --- a/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt index b6554cc..66cd457 100644 --- a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt index b6554cc..66cd457 100644 --- a/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt index 7c067b4..4f59480 100644 --- a/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -11,7 +11,7 @@ PDFtoZPL.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.DitheringKind PDFtoZPL.DitheringKind.None = 0 -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions PDFtoZPL.ZplOptions.ZplOptions() -> void -PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0) -> void +PDFtoZPL.ZplOptions.ZplOptions(PDFtoZPL.BitmapEncodingKind EncodingKind = PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, PDFtoZPL.DitheringKind DitheringKind = PDFtoZPL.DitheringKind.None, uint PrintQuantity = 0, sbyte LabelTop = 0, short LabelShift = 0) -> void PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.ZplOptions.DitheringKind.init -> void PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind @@ -24,6 +24,10 @@ PDFtoZPL.ZplOptions.SetLabelLength.get -> bool PDFtoZPL.ZplOptions.SetLabelLength.init -> void PDFtoZPL.ZplOptions.Threshold.get -> byte PDFtoZPL.ZplOptions.Threshold.init -> void +PDFtoZPL.ZplOptions.LabelShift.get -> short +PDFtoZPL.ZplOptions.LabelShift.init -> void +PDFtoZPL.ZplOptions.LabelTop.get -> sbyte +PDFtoZPL.ZplOptions.LabelTop.init -> void PDFtoZPL.IZplOptions PDFtoZPL.IZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind PDFtoZPL.IZplOptions.DitheringKind.init -> void @@ -37,6 +41,10 @@ PDFtoZPL.IZplOptions.SetLabelLength.get -> bool PDFtoZPL.IZplOptions.SetLabelLength.init -> void PDFtoZPL.IZplOptions.Threshold.get -> byte PDFtoZPL.IZplOptions.Threshold.init -> void +PDFtoZPL.IZplOptions.LabelShift.get -> short +PDFtoZPL.IZplOptions.LabelShift.init -> void +PDFtoZPL.IZplOptions.LabelTop.get -> sbyte +PDFtoZPL.IZplOptions.LabelTop.init -> void PDFtoZPL.PdfOptions PDFtoZPL.PdfOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing PDFtoZPL.PdfOptions.AntiAliasing.init -> void diff --git a/PDFtoZPL/ShiftingUtils.cs b/PDFtoZPL/ShiftingUtils.cs new file mode 100644 index 0000000..8e8602b --- /dev/null +++ b/PDFtoZPL/ShiftingUtils.cs @@ -0,0 +1,28 @@ +using SkiaSharp; +using System; + +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("PDFtoZPL.WebConverter, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fd0018feed1ba4fac91744d868cb1bb8a4b55a97eec0e02e90a8d57db56bff5a32f03813b1a6c8a7ccd50eed8880be4e91ad281c9ee81fd4182de0905c0590019e9bf87a8f83ce93c09da9c4eaae5bd8aa63816c4a3bef8bd16bb358d3aed64cc2ec3ae17698c336b63df4fbd719dc13bd9a88d9fcfa87a2426d34db78d05fb7")] + +namespace PDFtoZPL +{ + internal static class ShiftingUtils + { + public static SKBitmap ApplyShift(this SKBitmap input, sbyte labelTop, short labelShift, SKColor backgroundColor) + { + labelTop = (sbyte)Math.Min((short)120, Math.Max((short)0, labelTop)); + labelShift = Math.Max((short)-9999, Math.Min((short)0, labelShift)); + + if (labelTop == 0 && labelShift == 0) + return input; + + var output = new SKBitmap(input.Width, input.Height, SKColorType.Bgra8888, SKAlphaType.Premul); + + using var canvas = new SKCanvas(output); + canvas.Clear(backgroundColor); + canvas.DrawBitmap(input, new SKPoint(-labelShift, labelTop)); + canvas.Flush(); + + return output; + } + } +} \ No newline at end of file diff --git a/PDFtoZPL/ZplOptions.cs b/PDFtoZPL/ZplOptions.cs index 74b1fdd..aae2c76 100644 --- a/PDFtoZPL/ZplOptions.cs +++ b/PDFtoZPL/ZplOptions.cs @@ -9,18 +9,22 @@ /// The threshold below which a pixel is considered black. Lower values mean darker, higher mean lighter. /// The dithering algorithm used when downsampling to a 1-bit monochrome image. /// Adds the ^PQ command to set the total quantity of labels to print. Accepted values are 1 to 99,999,999. Ignored if set to 0. + /// Adds the ^LT command to move the entire label up or down from its current position (in relation to the top edge of the label). Valid values are between 120 (move label down) and -120 (move label up) dot rows. Values outside of this range are ignored and some printers might accept even fewer. + /// Adds the ^LS command to move the entire label left or right from its current position. Valid values are between 9999 (move label left) and -9999 (move label right). Values outside of this range are ignored. public readonly record struct ZplOptions( BitmapEncodingKind EncodingKind = BitmapEncodingKind.HexadecimalCompressed, bool GraphicFieldOnly = false, bool SetLabelLength = false, byte Threshold = 128, DitheringKind DitheringKind = DitheringKind.None, - uint PrintQuantity = 0) : IZplOptions + uint PrintQuantity = 0, + sbyte LabelTop = 0, + short LabelShift = 0) : IZplOptions { /// /// Constructs with default values. /// - public ZplOptions() : this(BitmapEncodingKind.HexadecimalCompressed, false, false, 128, DitheringKind.None, 0) { } + public ZplOptions() : this(BitmapEncodingKind.HexadecimalCompressed, false, false, 128, DitheringKind.None, 0, 0, 0) { } } } #if NETSTANDARD || NETFRAMEWORK diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 1982a5d..400eb6f 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -66,7 +66,7 @@ - - + + \ No newline at end of file diff --git a/WebConverter/Models/RenderRequest.cs b/WebConverter/Models/RenderRequest.cs index 67eed60..d366682 100644 --- a/WebConverter/Models/RenderRequest.cs +++ b/WebConverter/Models/RenderRequest.cs @@ -149,6 +149,20 @@ public int ThresholdAsInt [Range(1, 99999999)] public int PrintQuantity { get; set; } = 1; + [Required] + public bool UseLabelTop { get; set; } = false; + + [Required] + [Range(-120, 120)] + public int LabelTop { get; set; } = 0; + + [Required] + public bool UseLabelShift { get; set; } = false; + + [Required] + [Range(-9999, 9999)] + public int LabelShift { get; set; } = 0; + public static string GetDitheringLocalized(DitheringKind dithering) => dithering switch { DitheringKind.None => "None", diff --git a/WebConverter/Pages/Index.razor b/WebConverter/Pages/Index.razor index 3539553..c9eac59 100644 --- a/WebConverter/Pages/Index.razor +++ b/WebConverter/Pages/Index.razor @@ -124,15 +124,35 @@ -
+
- +
+ +
+
+ + +
+
+ +
+
+ +
+
+ + +
+
+ +
+
diff --git a/WebConverter/Pages/Index.razor.cs b/WebConverter/Pages/Index.razor.cs index 5f4bdce..e22109a 100644 --- a/WebConverter/Pages/Index.razor.cs +++ b/WebConverter/Pages/Index.razor.cs @@ -188,13 +188,17 @@ await Task.Factory.StartNew(() => SetLabelLength: Model.SetLabelLength, Threshold: Model.Threshold, DitheringKind: Model.Dithering, - PrintQuantity: Model.UsePrintQuantity ? (uint)Math.Max(Model.PrintQuantity, 1) : 0) + PrintQuantity: Model.UsePrintQuantity ? (uint)Math.Max(Model.PrintQuantity, 1) : 0, + LabelTop: (sbyte)(Model.UseLabelTop ? Model.LabelTop : 0), + LabelShift: (short)(Model.UseLabelShift ? Model.LabelShift : 0) + ) ); Model.OutputPreviewImage = new MemoryStream(); using var monochromeBitmap = inputToConvert.ToMonochrome(Model.Threshold, Model.Dithering); - encodeSuccess = monochromeBitmap.Encode(Model.OutputPreviewImage, SKEncodedImageFormat.Png, 100); + using var shiftedBitmap = monochromeBitmap.ApplyShift((sbyte)(Model.UseLabelTop ? Model.LabelTop : 0), (short)(Model.UseLabelShift ? Model.LabelShift : 0), backgroundColor); + encodeSuccess = shiftedBitmap.Encode(Model.OutputPreviewImage, SKEncodedImageFormat.Png, 100); } finally { diff --git a/WebConverter/WebConverter.csproj b/WebConverter/WebConverter.csproj index 06c964a..29a0155 100644 --- a/WebConverter/WebConverter.csproj +++ b/WebConverter/WebConverter.csproj @@ -7,7 +7,7 @@ PDFtoZPL.WebConverter PDFtoZPL.WebConverter PDFtoZPL.WebConverter.Program - 5.2.0 + 5.3.0 true true