From 70c7067f3950b15bbf5d447a3ce9afcd62cf81b0 Mon Sep 17 00:00:00 2001 From: David Sungaila Date: Fri, 28 Jun 2024 16:27:01 +0200 Subject: [PATCH] Update to PDFtoImage 4.0.2 (#57) --- .github/workflows/dotnet.yml | 13 +++++++------ Console/Program.cs | 8 +++++--- PDFtoZPL/ConversionUtils.cs | 2 +- PDFtoZPL/PDFtoZPL.csproj | 5 +++-- PDFtoZPL/PdfOptions.cs | 11 +++++++---- .../PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt | 4 +++- .../monoandroid10.0/PublicAPI.Unshipped.txt | 5 ++++- PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt | 4 +++- PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt | 4 +++- PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt | 4 +++- PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt | 4 +++- .../PublicAPI/net7.0-android/PublicAPI.Shipped.txt | 4 +++- .../net7.0-android/PublicAPI.Unshipped.txt | 5 ++++- PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt | 4 +++- .../PublicAPI/net8.0-android/PublicAPI.Shipped.txt | 4 +++- .../net8.0-android/PublicAPI.Unshipped.txt | 4 +++- PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt | 4 +++- .../PublicAPI/netstandard2.0/PublicAPI.Shipped.txt | 4 +++- Tests/AntiAliasingTests.cs | 2 ++ Tests/BackgroundColorTests.cs | 2 ++ Tests/DitheringTests.cs | 2 ++ Tests/EncodingTests.cs | 4 +++- Tests/PdfMultipleConversionTests.cs | 2 ++ Tests/PdfRotationTests.cs | 2 ++ WebConverter/Models/RenderRequest.cs | 1 + WebConverter/Pages/Index.razor | 9 ++++++++- WebConverter/Pages/Index.razor.cs | 3 ++- 27 files changed, 88 insertions(+), 32 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 283850e..b1b85c5 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -107,7 +107,7 @@ jobs: !**/*.snupkg if-no-files-found: error - name: Publish NuGet packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@main with: name: NuGet packages path: | @@ -115,13 +115,14 @@ jobs: PDFtoZPL/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg if-no-files-found: error - name: Publish tests - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@main if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true with: name: Test assemblies path: Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} if-no-files-found: error retention-days: 1 + compression-level: 9 test: name: Test (${{ matrix.os }}) needs: build @@ -145,7 +146,7 @@ jobs: with: dotnet-version: 8.x - name: Download test assemblies - uses: actions/download-artifact@v4 + uses: actions/download-artifact@main with: name: Test assemblies - name: .NET Framework 4.6.2 @@ -168,7 +169,7 @@ jobs: run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed - name: Upload test results if: success() || failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@main with: name: Test results (${{ matrix.os }}) path: ./**/*.trx @@ -187,7 +188,7 @@ jobs: if: (success() || failure()) && (github.event_name != 'workflow_dispatch' && true || inputs.publish_testresults) == true steps: - name: Download Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@main with: pattern: Test results (*) merge-multiple: true @@ -255,7 +256,7 @@ jobs: restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v3 + uses: actions/cache@main with: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner diff --git a/Console/Program.cs b/Console/Program.cs index 01f4efb..5f8cafb 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -5,6 +5,10 @@ namespace PDFtoZPL.Console { +#if NET6_0_OR_GREATER +#pragma warning disable CA1416 +#endif + #if NET8_0_OR_GREATER #pragma warning disable CA1510 // Use ArgumentNullException throw helper #endif @@ -36,9 +40,7 @@ public static int Main(string[] args) #else true #endif -#pragma warning disable CA1416 - ? Conversion.ConvertPdfPage(inputStream, page: page - 1, pdfOptions: new (Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill), zplOptions: new (EncodingKind: encodingKind)) -#pragma warning restore CA1416 + ? Conversion.ConvertPdfPage(inputStream, page: page - 1, pdfOptions: new(Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill), zplOptions: new(EncodingKind: encodingKind)) : 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."), }; diff --git a/PDFtoZPL/ConversionUtils.cs b/PDFtoZPL/ConversionUtils.cs index aa1f6c2..14a25c3 100644 --- a/PDFtoZPL/ConversionUtils.cs +++ b/PDFtoZPL/ConversionUtils.cs @@ -28,7 +28,7 @@ public static byte[] HexToByteArray(string input) for (int i = 0; i < input.Length; i += 2) result.Add(_hexLookupTable[input.Substring(i, 2)]); - return result.ToArray(); + return [.. result]; } public static string ConvertBitmapToHex(SKBitmap pdfBitmap, byte threshold, out int binaryByteCount, out int bytesPerRow) diff --git a/PDFtoZPL/PDFtoZPL.csproj b/PDFtoZPL/PDFtoZPL.csproj index 2f4e6e5..de7b8c8 100644 --- a/PDFtoZPL/PDFtoZPL.csproj +++ b/PDFtoZPL/PDFtoZPL.csproj @@ -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. - - Revert from 300 to 203 as default DPI when no pdfOptions was specified. This is a breaking change. + - Revert from 300 to 203 as default DPI when no pdfOptions was specified. This is a breaking change. +- Added optional parameter DpiRelativeToBounds. PDF ZPL Zebra Bitmap Convert Conversion C# PDFium MAUI wasm WebAssembly https://github.com/sungaila/PDFtoZPL.git git @@ -66,7 +67,7 @@ - + diff --git a/PDFtoZPL/PdfOptions.cs b/PDFtoZPL/PdfOptions.cs index e656632..90aa4af 100644 --- a/PDFtoZPL/PdfOptions.cs +++ b/PDFtoZPL/PdfOptions.cs @@ -16,8 +16,9 @@ namespace PDFtoZPL /// Specifies the rotation at 90 degree intervals. /// Specifies which parts of the PDF should be anti-aliasing for rendering. /// Specifies the background color. Defaults to . - /// Specifies the bounds for the page relative to . This can be used for clipping (bounds inside of page) or additional margins (bounds outside of page). + /// Specifies the bounds for the page relative to . This can be used for clipping (bounds inside of page) or additional margins (bounds outside of page). The bound units are relative to the PDF size (at 72 DPI). /// Specifies that the PDF should be rendered as several segments and merged into the final image. This can help in cases where the output image is too large, causing corrupted images (e.g. missing text) or crashes. + /// Specifies that and will be calculated relative to instead of the original PDF. public readonly record struct PdfOptions( int Dpi = 203, int? Width = null, @@ -29,12 +30,13 @@ public readonly record struct PdfOptions( PdfAntiAliasing AntiAliasing = PdfAntiAliasing.All, SKColor? BackgroundColor = null, RectangleF? Bounds = null, - bool UseTiling = false) + bool UseTiling = false, + bool DpiRelativeToBounds = false) : IRenderOptions { /// /// Constructs with default values. /// - public PdfOptions() : this(203, null, null, false, false, false, PdfRotation.Rotate0, PdfAntiAliasing.All, null, null, false) { } + public PdfOptions() : this(203, null, null, false, false, false, PdfRotation.Rotate0, PdfAntiAliasing.All, null, null, false, false) { } /// /// Implicit conversion to . @@ -51,6 +53,7 @@ public PdfOptions() : this(203, null, null, false, false, false, PdfRotation.Rot pdfOptions.AntiAliasing, pdfOptions.BackgroundColor, pdfOptions.Bounds, - pdfOptions.UseTiling); + pdfOptions.UseTiling, + pdfOptions.DpiRelativeToBounds); } } \ No newline at end of file diff --git a/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt index 860a526..8e15731 100644 --- a/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt b/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt index 91b0e1a..d38cea1 100644 --- a/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt +++ b/PDFtoZPL/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt @@ -1 +1,4 @@ -#nullable enable \ No newline at end of file +#nullable enable +PDFtoZPL.Resource +PDFtoZPL.Resource.Attribute +PDFtoZPL.Resource.Resource() -> void \ No newline at end of file diff --git a/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt index 860a526..8e15731 100644 --- a/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net462/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt index 860a526..8e15731 100644 --- a/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net471/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt index 860a526..8e15731 100644 --- a/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net481/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt index 71d3339..88a151a 100644 --- a/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Shipped.txt index 71d3339..88a151a 100644 --- a/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt b/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt index 91b0e1a..d38cea1 100644 --- a/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt +++ b/PDFtoZPL/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt @@ -1 +1,4 @@ -#nullable enable \ No newline at end of file +#nullable enable +PDFtoZPL.Resource +PDFtoZPL.Resource.Attribute +PDFtoZPL.Resource.Resource() -> void \ No newline at end of file diff --git a/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt index 71d3339..88a151a 100644 --- a/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net7.0/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt index 71d3339..88a151a 100644 --- a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Unshipped.txt b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Unshipped.txt index 91b0e1a..c907b8d 100644 --- a/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Unshipped.txt +++ b/PDFtoZPL/PublicAPI/net8.0-android/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ -#nullable enable \ No newline at end of file +#nullable enable +PDFtoZPL.Resource +PDFtoZPL.Resource.Resource() -> void \ No newline at end of file diff --git a/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt index 71d3339..88a151a 100644 --- a/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt index 860a526..8e15731 100644 --- a/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ b/PDFtoZPL/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -57,7 +57,9 @@ PDFtoZPL.PdfOptions.WithFormFill.get -> bool PDFtoZPL.PdfOptions.WithFormFill.init -> void PDFtoZPL.PdfOptions.UseTiling.get -> bool PDFtoZPL.PdfOptions.UseTiling.init -> void -PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false) -> void +PDFtoZPL.PdfOptions.DpiRelativeToBounds.get -> bool +PDFtoZPL.PdfOptions.DpiRelativeToBounds.init -> void +PDFtoZPL.PdfOptions.PdfOptions(int Dpi = 203, int? Width = null, int? Height = null, bool WithAnnotations = false, bool WithFormFill = false, bool WithAspectRatio = false, PDFtoImage.PdfRotation Rotation = PDFtoImage.PdfRotation.Rotate0, PDFtoImage.PdfAntiAliasing AntiAliasing = PDFtoImage.PdfAntiAliasing.All, SkiaSharp.SKColor? BackgroundColor = null, System.Drawing.RectangleF? Bounds = null, bool UseTiling = false, bool DpiRelativeToBounds = false) -> void static PDFtoZPL.PdfOptions.implicit operator PDFtoImage.RenderOptions(PDFtoZPL.PdfOptions pdfOptions) -> PDFtoImage.RenderOptions 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! diff --git a/Tests/AntiAliasingTests.cs b/Tests/AntiAliasingTests.cs index dde67b9..f14843a 100644 --- a/Tests/AntiAliasingTests.cs +++ b/Tests/AntiAliasingTests.cs @@ -19,7 +19,9 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif [TestMethod] [DataRow("SocialPreview.pdf", null, DisplayName = "Default (None)")] diff --git a/Tests/BackgroundColorTests.cs b/Tests/BackgroundColorTests.cs index e87e6c2..53261f5 100644 --- a/Tests/BackgroundColorTests.cs +++ b/Tests/BackgroundColorTests.cs @@ -18,7 +18,9 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif [TestMethod] [DataRow("SocialPreview.pdf", null, DisplayName = "Default (White)")] diff --git a/Tests/DitheringTests.cs b/Tests/DitheringTests.cs index 8e2a728..c55264b 100644 --- a/Tests/DitheringTests.cs +++ b/Tests/DitheringTests.cs @@ -18,7 +18,9 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif [TestMethod] [DataRow("SocialPreview.pdf", null)] diff --git a/Tests/EncodingTests.cs b/Tests/EncodingTests.cs index 8a32ab8..e6be47c 100644 --- a/Tests/EncodingTests.cs +++ b/Tests/EncodingTests.cs @@ -18,9 +18,11 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif - [TestMethod] + [TestMethod] [DataRow("SocialPreview.pdf", null)] [DataRow("SocialPreview.pdf", BitmapEncodingKind.Hexadecimal)] [DataRow("SocialPreview.pdf", BitmapEncodingKind.HexadecimalCompressed)] diff --git a/Tests/PdfMultipleConversionTests.cs b/Tests/PdfMultipleConversionTests.cs index 746ff0d..5d7fd55 100644 --- a/Tests/PdfMultipleConversionTests.cs +++ b/Tests/PdfMultipleConversionTests.cs @@ -19,7 +19,9 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif private static readonly string[] _expectedZplResults = [ diff --git a/Tests/PdfRotationTests.cs b/Tests/PdfRotationTests.cs index be762fc..17e4c26 100644 --- a/Tests/PdfRotationTests.cs +++ b/Tests/PdfRotationTests.cs @@ -19,7 +19,9 @@ public void Initialize() #endif } +#if NET6_0_OR_GREATER #pragma warning disable CA1416 +#endif [TestMethod] [DataRow("SocialPreview.pdf", null)] diff --git a/WebConverter/Models/RenderRequest.cs b/WebConverter/Models/RenderRequest.cs index 494b182..4b62527 100644 --- a/WebConverter/Models/RenderRequest.cs +++ b/WebConverter/Models/RenderRequest.cs @@ -140,6 +140,7 @@ public int ThresholdAsInt [Required] public bool UseTiling { get; set; } = true; + public bool DpiRelativeToBounds { get; set; } = false; public static string GetDitheringLocalized(DitheringKind dithering) => dithering switch { DitheringKind.None => "None", diff --git a/WebConverter/Pages/Index.razor b/WebConverter/Pages/Index.razor index 944690a..eb1b0eb 100644 --- a/WebConverter/Pages/Index.razor +++ b/WebConverter/Pages/Index.razor @@ -243,7 +243,7 @@ This option can help with rendering problems (e.g. missing text) at very high re -
+
@@ -254,6 +254,13 @@ This option can help with rendering problems (e.g. missing text) at very high re
+ +
+
+ + +
+
diff --git a/WebConverter/Pages/Index.razor.cs b/WebConverter/Pages/Index.razor.cs index 24099ad..448ca58 100644 --- a/WebConverter/Pages/Index.razor.cs +++ b/WebConverter/Pages/Index.razor.cs @@ -167,7 +167,8 @@ await Task.Factory.StartNew(() => AntiAliasing: antiAliasing, BackgroundColor: backgroundColor, Bounds: Model.UseBounds ? new RectangleF(Model.BoundsX, Model.BoundsY, Model.BoundsWidth, Model.BoundsHeight) : null, - UseTiling: Model.UseTiling) + UseTiling: Model.UseTiling, + DpiRelativeToBounds: Model.DpiRelativeToBounds) ); } else