Skip to content

Commit

Permalink
Update to PDFtoImage 4.0.0 (#49)
Browse files Browse the repository at this point in the history
* Update to PDFtoImage 4.0.0

* Update unit tests
  • Loading branch information
sungaila authored Feb 29, 2024
1 parent 5248cc1 commit b131832
Show file tree
Hide file tree
Showing 40 changed files with 1,317 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: PDFtoZPL version
description: Which version of PDFtoZPL is affected?
value: 4.1.0
value: 5.0.0
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static int Main(string[] args)
true
#endif
#pragma warning disable CA1416
? Conversion.ConvertPdfPage(inputStream, page: page - 1, dpi: dpi, withAnnotations: withAnnotations, withFormFill: withFormFill, encodingKind: encodingKind)
? Conversion.ConvertPdfPage(inputStream, page: page - 1, pdfOptions: new (Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill), zplOptions: new (EncodingKind: encodingKind))
#pragma warning restore CA1416
: throw new NotSupportedException("Only win-x86, win-x64, win-arm64, linux-x64, linux-arm, linux-arm64, osx-x64 and osx-arm64 are supported for PDF file conversion."),
_ => throw new InvalidOperationException("The given input file path must have pdf as file extension."),
Expand Down
31 changes: 31 additions & 0 deletions PDFtoZPL/BitmapEncodingKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace PDFtoZPL
{
/// <summary>
/// The supported encoding options for the bitmap within the generated ZPL code.
/// </summary>
public enum BitmapEncodingKind
{
/// <summary>
/// <b>Not recommended.</b> The bitmap is encoded as hexadecimals.<br/>
/// Its output might be to large for the printer's bitmap storage area.
/// </summary>
Hexadecimal,

/// <summary>
/// The bitmap is encoded as hexadecimals and then compressed (via ZPL ASCII compression).<br/>
/// It's significantly more space-saving than <see cref="Hexadecimal"/>.
/// </summary>
HexadecimalCompressed,

/// <summary>
/// <b>Not recommended.</b> The bitmap is encoded as Base64 (MIME). This encoding is referred to as <b>B64</b> in the ZPL II programming guide.<br/>
/// Its output might be to large for the printer's bitmap storage area. Still more space-saving than <see cref="Hexadecimal"/> though.
/// </summary>
Base64,

/// <summary>
/// Recommended. The bitmap is compressed with Deflate (RFC 1951) and then encoded as Base64 (MIME). This encoding is referred to as <b>Z64</b> in the ZPL II programming guide.
/// </summary>
Base64Compressed
}
}
430 changes: 71 additions & 359 deletions PDFtoZPL/Conversion.cs

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions PDFtoZPL/DitheringKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace PDFtoZPL
{
/// <summary>
/// The used dithering algorithem after downsampling to 1 bit monochrome.
/// </summary>
public enum DitheringKind
{
/// <summary>
/// No dithering.
/// </summary>
None,

/// <summary>
/// Use the Robert W. Floyd and Louis Steinberg dithering algorithm.
/// </summary>
FloydSteinberg,

/// <summary>
/// Use the Bill Atkinson dithering algorithm.
/// </summary>
Atkinson
}
}
10 changes: 5 additions & 5 deletions PDFtoZPL/PDFtoZPL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- NuGet -->
<PropertyGroup>
<VersionPrefix>4.1.0</VersionPrefix>
<VersionPrefix>5.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>David Sungaila</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -21,9 +21,9 @@
<PackageProjectUrl>https://github.com/sungaila/PDFtoZPL</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/sungaila/PDFtoZPL/master/Icon_128.png</PackageIconUrl>
<Description>A .NET library to convert PDF files (and bitmaps) into Zebra Programming Language code.</Description>
<PackageReleaseNotes>- Added support for Mono.
- Added support for Unity.
- Added support for UWP.</PackageReleaseNotes>
<PackageReleaseNotes>- Added optional parameter Bounds.
- Added optional parameter UseTiling.
- RenderOptions and ZplOptions introduced for most API calls. This is a breaking change.</PackageReleaseNotes>
<PackageTags>PDF ZPL Zebra Bitmap Convert Conversion C# PDFium MAUI wasm WebAssembly</PackageTags>
<RepositoryUrl>https://github.com/sungaila/PDFtoZPL.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down Expand Up @@ -68,7 +68,7 @@

<!-- SourceLink build steps and NuGet packages -->
<ItemGroup>
<PackageReference Include="PDFtoImage" Version="3.1.0" PrivateAssets="analyzers" />
<PackageReference Include="PDFtoImage" Version="4.0.0" PrivateAssets="analyzers" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="SharpZipLib" Version="1.4.2" PrivateAssets="analyzers" />
</ItemGroup>
Expand Down
54 changes: 32 additions & 22 deletions PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
#nullable enable
PDFtoZPL.BitmapEncodingKind
PDFtoZPL.BitmapEncodingKind.Base64 = 2 -> PDFtoZPL.BitmapEncodingKind
PDFtoZPL.BitmapEncodingKind.Base64Compressed = 3 -> PDFtoZPL.BitmapEncodingKind
PDFtoZPL.BitmapEncodingKind.Hexadecimal = 0 -> PDFtoZPL.BitmapEncodingKind
PDFtoZPL.BitmapEncodingKind.HexadecimalCompressed = 1 -> PDFtoZPL.BitmapEncodingKind
PDFtoZPL.Conversion
static PDFtoZPL.Conversion.ConvertBitmap(byte[]! bitmapAsByteArray, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool setLabelLength = false, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(string! bitmapPath, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool setLabelLength = false, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(System.IO.Stream! bitmapAsStream, bool leaveOpen, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool setLabelLength = false, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(System.IO.Stream! bitmapAsStream, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool setLabelLength = false, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(SkiaSharp.SKBitmap! bitmap, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool setLabelLength = false, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None) -> string!
static PDFtoZPL.Conversion.ConvertPdf(byte[]! pdfAsByteArray, string? password = null, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdf(string! pdfAsBase64String, string? password = null, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdf(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdf(System.IO.Stream! pdfStream, string? password = null, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdfPage(byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> string!
static PDFtoZPL.Conversion.ConvertPdfPage(string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> string!
static PDFtoZPL.Conversion.ConvertPdfPage(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int page = 0, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> string!
static PDFtoZPL.Conversion.ConvertPdfPage(System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 203, int? width = null, int? height = null, bool withAnnotations = false, bool withFormFill = false, PDFtoZPL.Conversion.BitmapEncodingKind encodingKind = PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed, bool graphicFieldOnly = false, bool withAspectRatio = false, bool setLabelLength = false, PDFtoImage.PdfRotation rotation = PDFtoImage.PdfRotation.Rotate0, byte threshold = 128, PDFtoZPL.Conversion.DitheringKind ditheringKind = PDFtoZPL.Conversion.DitheringKind.None, PDFtoImage.PdfAntiAliasing antiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? backgroundColor = null) -> string!
PDFtoZPL.Conversion.BitmapEncodingKind
PDFtoZPL.Conversion.BitmapEncodingKind.Hexadecimal = 0 -> PDFtoZPL.Conversion.BitmapEncodingKind
PDFtoZPL.Conversion.BitmapEncodingKind.HexadecimalCompressed = 1 -> PDFtoZPL.Conversion.BitmapEncodingKind
PDFtoZPL.Conversion.BitmapEncodingKind.Base64 = 2 -> PDFtoZPL.Conversion.BitmapEncodingKind
PDFtoZPL.Conversion.BitmapEncodingKind.Base64Compressed = 3 -> PDFtoZPL.Conversion.BitmapEncodingKind
PDFtoZPL.Conversion.DitheringKind
PDFtoZPL.Conversion.DitheringKind.Atkinson = 2 -> PDFtoZPL.Conversion.DitheringKind
PDFtoZPL.Conversion.DitheringKind.FloydSteinberg = 1 -> PDFtoZPL.Conversion.DitheringKind
PDFtoZPL.Conversion.DitheringKind.None = 0 -> PDFtoZPL.Conversion.DitheringKind
PDFtoZPL.DitheringKind
PDFtoZPL.DitheringKind.Atkinson = 2 -> PDFtoZPL.DitheringKind
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) -> void
PDFtoZPL.ZplOptions.DitheringKind.get -> PDFtoZPL.DitheringKind
PDFtoZPL.ZplOptions.DitheringKind.init -> void
PDFtoZPL.ZplOptions.EncodingKind.get -> PDFtoZPL.BitmapEncodingKind
PDFtoZPL.ZplOptions.EncodingKind.init -> void
PDFtoZPL.ZplOptions.GraphicFieldOnly.get -> bool
PDFtoZPL.ZplOptions.GraphicFieldOnly.init -> void
PDFtoZPL.ZplOptions.SetLabelLength.get -> bool
PDFtoZPL.ZplOptions.SetLabelLength.init -> void
PDFtoZPL.ZplOptions.Threshold.get -> byte
PDFtoZPL.ZplOptions.Threshold.init -> void
static PDFtoZPL.Conversion.ConvertBitmap(byte[]! bitmapAsByteArray, PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(SkiaSharp.SKBitmap! bitmap, PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(string! bitmapPath, PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertBitmap(System.IO.Stream! bitmapAsStream, bool leaveOpen = false, PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertPdf(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdf(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdf(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> System.Collections.Generic.IEnumerable<string!>!
static PDFtoZPL.Conversion.ConvertPdfPage(byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertPdfPage(string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
static PDFtoZPL.Conversion.ConvertPdfPage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions pdfOptions = default(PDFtoImage.RenderOptions), PDFtoZPL.ZplOptions zplOptions = default(PDFtoZPL.ZplOptions)) -> string!
Loading

0 comments on commit b131832

Please sign in to comment.