From e946ca0374f03db0cbc6d5af7e6ce2227b1eaa0f Mon Sep 17 00:00:00 2001 From: David Sungaila Date: Wed, 24 Jul 2024 23:39:21 +0200 Subject: [PATCH] Add methods for page indices, ranges and selection (#92) * Prepare API for batching; remove deprecated .NET 7 and Xamarin * Add index, range and selection based methods * Add unit tests for new methods * Update version to 4.1.0 --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/workflows/dotnet.yml | 96 +-- .github/workflows/githubpages.yml | 8 +- .github/workflows/githubpages_staging.yml | 14 +- src/Console/Console.csproj | 4 +- src/FrameworkTests/AotConsole/Program.cs | 2 +- .../AspNet/Properties/AssemblyInfo.cs | 1 - src/FrameworkTests/AspNetCore/Program.cs | 2 +- src/FrameworkTests/MauiApp/MainPage.xaml.cs | 2 +- src/FrameworkTests/MauiApp/MauiApp.csproj | 4 +- .../MauiApp/Platforms/Android/MainActivity.cs | 1 - .../MauiApp/Platforms/Windows/App.xaml.cs | 4 +- .../Uwp/Properties/AssemblyInfo.cs | 1 - src/PDFtoImage.Build.slnf | 1 - src/PDFtoImage.sln | 101 +-- src/PDFtoImage/Conversion.Base64.cs | 301 +++++++ src/PDFtoImage/Conversion.ByteArray.cs | 331 ++++++++ src/PDFtoImage/Conversion.Deprecated.cs | 510 ++++++++++++ src/PDFtoImage/Conversion.Stream.cs | 362 +++++++++ src/PDFtoImage/Conversion.cs | 692 +--------------- src/PDFtoImage/Internals/IsExternalInit.cs | 2 +- src/PDFtoImage/PDFtoImage.csproj | 26 +- .../monoandroid10.0/PublicAPI.Shipped.txt | 139 ---- .../monoandroid10.0/PublicAPI.Unshipped.txt | 4 - .../PublicAPI/net462/PublicAPI.Shipped.txt | 5 +- .../PublicAPI/net471/PublicAPI.Shipped.txt | 5 +- .../PublicAPI/net481/PublicAPI.Shipped.txt | 5 +- .../PublicAPI/net6.0/PublicAPI.Shipped.txt | 38 +- .../net7.0-android/PublicAPI.Shipped.txt | 146 ---- .../net7.0-android/PublicAPI.Unshipped.txt | 4 - .../PublicAPI/net7.0/PublicAPI.Shipped.txt | 38 +- .../net8.0-android/PublicAPI.Shipped.txt | 38 +- .../PublicAPI/net8.0/PublicAPI.Shipped.txt | 38 +- .../netstandard2.0/PublicAPI.Shipped.txt | 5 +- src/Tests/ApiTests.cs | 626 +++++++-------- src/Tests/AspectRatioTests.cs | 756 ++++++++--------- src/Tests/BatchingTests.cs | 281 +++++++ src/Tests/ComparisonTests.cs | 572 ++++++------- src/Tests/Compatibility/AntiAliasingTests.cs | 2 - src/Tests/Compatibility/ApiTests.cs | 313 ++++---- src/Tests/Compatibility/AspectRatioTests.cs | 757 +++++++++--------- .../Compatibility/BackgroundColorTests.cs | 1 - src/Tests/Compatibility/ComparisonTests.cs | 1 - src/Tests/Compatibility/ExceptionTests.cs | 28 +- src/Tests/Compatibility/FormFillTests.cs | 104 ++- src/Tests/Compatibility/RotationTests.cs | 245 +++--- src/Tests/ExceptionTests.cs | 38 +- src/Tests/FormFillTests.cs | 106 +-- src/Tests/PasswordTests.cs | 56 +- src/Tests/QueryTests.cs | 118 +-- src/Tests/RotationTests.cs | 244 +++--- src/Tests/TestBase.cs | 20 +- src/Tests/Tests.csproj | 6 +- src/WebConverter/Models/DummyFile.cs | 8 +- src/WebConverter/Models/FileStringyfied.cs | 42 +- src/WebConverter/Models/FilesStringyfied.cs | 20 +- .../Models/UnixDateTimeConverter.cs | 22 +- src/WebConverter/Pages/Index.razor.cs | 6 +- src/WebConverter/WebConverter.csproj | 6 +- 59 files changed, 4135 insertions(+), 3175 deletions(-) create mode 100644 src/PDFtoImage/Conversion.Base64.cs create mode 100644 src/PDFtoImage/Conversion.ByteArray.cs create mode 100644 src/PDFtoImage/Conversion.Deprecated.cs create mode 100644 src/PDFtoImage/Conversion.Stream.cs delete mode 100644 src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt delete mode 100644 src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt delete mode 100644 src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Shipped.txt delete mode 100644 src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt create mode 100644 src/Tests/BatchingTests.cs diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 7d231ec0..3e77b941 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: attributes: label: PDFtoImage version description: Which version of PDFtoImage is affected? - value: 4.0.2 + value: 4.1.0 validations: required: true - type: dropdown diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 05426bb7..490da881 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -65,56 +65,25 @@ jobs: uses: actions/checkout@main with: fetch-depth: 0 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@main - with: - msbuild-architecture: x64 - - name: Setup .NET 6 - uses: actions/setup-dotnet@main - with: - dotnet-version: 6.x - - name: Setup .NET 7 + - name: Setup .NET uses: actions/setup-dotnet@main with: - dotnet-version: 7.x - - name: Setup .NET 8 - uses: actions/setup-dotnet@main - with: - dotnet-version: 8.x - - name: Setup .NET workload android - run: dotnet workload install android + dotnet-version: | + 6.x + 7.x + 8.x - name: Setup .NET workload maui-android run: dotnet workload install maui-android - - name: Setup .NET workload ios - run: dotnet workload install ios - - name: Setup .NET workload maui-ios - run: dotnet workload install maui-ios - - name: Setup .NET workload maccatalyst - run: dotnet workload install maccatalyst - - name: Setup .NET workload maui-maccatalyst - run: dotnet workload install maui-maccatalyst - name: Setup .NET workload maui-windows run: dotnet workload install maui-windows - name: Setup .NET workload wasm-tools run: dotnet workload install wasm-tools - - name: Setup JDK 17 - uses: actions/setup-java@main - with: - java-version: 17 - java-package: jdk - distribution: 'zulu' - - name: Setup Android SDK 29 - run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" - - name: Setup Windows 11 SDK (10.0.26100.0) - uses: GuillaumeFalourd/setup-windows10-sdk-action@main - with: - sdk-version: 26100 - name: Restore - run: msbuild src/PDFtoImage.Build.slnf /t:restore + run: dotnet restore src/PDFtoImage.Build.slnf - name: Build - run: msbuild src/PDFtoImage.Build.slnf /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false + run: dotnet build src/PDFtoImage.Build.slnf -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} -p:VersionSuffix=ci --no-restore - name: Pack - run: msbuild src/PDFtoImage/PDFtoImage.csproj /t:pack /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false + run: dotnet pack src/PDFtoImage/PDFtoImage.csproj -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} -p:VersionSuffix=ci --no-restore - name: Generate artifact attestation uses: actions/attest-build-provenance@main with: @@ -166,18 +135,14 @@ jobs: - name: Setup Mono if: runner.os == 'Windows' run: choco install mono -y && Add-Content $env:GITHUB_PATH "C:\Program Files\Mono\bin" - - name: Setup .NET 6 + - name: Setup .NET uses: actions/setup-dotnet@main with: - dotnet-version: 6.x - - name: Setup .NET 7 - uses: actions/setup-dotnet@main - with: - dotnet-version: 7.x - - name: Setup .NET 8 - uses: actions/setup-dotnet@main - with: - dotnet-version: 8.x + dotnet-version: | + 6.x + 7.x + 8.x + dotnet-quality: 'preview' - name: Download test project MonoConsole uses: actions/download-artifact@main with: @@ -211,7 +176,7 @@ jobs: run: dotnet test net6.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net6.0/SaveOutputInGeneratedFolder.runsettings' || '' }} - name: .NET 7 if: success() || failure() - run: dotnet test net7.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net7.0/SaveOutputInGeneratedFolder.runsettings' || '' }} + run: dotnet test net7.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }} - name: .NET 8 if: success() || failure() run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }} @@ -317,34 +282,24 @@ jobs: uses: actions/checkout@main with: fetch-depth: 0 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@main - with: - msbuild-architecture: x64 - - name: Setup .NET 6 + - name: Setup .NET uses: actions/setup-dotnet@main with: - dotnet-version: 6.x - - name: Setup .NET 7 - uses: actions/setup-dotnet@main - with: - dotnet-version: 7.x - - name: Setup .NET 8 - uses: actions/setup-dotnet@main - with: - dotnet-version: 8.x + dotnet-version: | + 6.x + 7.x + 8.x + dotnet-quality: 'preview' + - name: Setup .NET workload maui-android + run: dotnet workload install maui-android - name: Setup dotnet-coverage run: dotnet tool install --global dotnet-coverage - - name: Setup .NET workload android - run: dotnet workload install android - name: Setup JDK 17 uses: actions/setup-java@main with: java-version: 17 java-package: jdk distribution: 'zulu' - - name: Setup Android SDK 29 - run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" - name: Cache SonarCloud packages uses: actions/cache@main with: @@ -371,7 +326,6 @@ jobs: shell: powershell run: | .\.sonar\scanner\dotnet-sonarscanner begin /k:"sungaila_PDFtoImage" /o:"sungaila" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml - dotnet restore src/PDFtoImage.SonarCloud.slnf - msbuild src/PDFtoImage.SonarCloud.slnf /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} + dotnet build src/PDFtoImage.SonarCloud.slnf -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} dotnet-coverage collect "dotnet test src/PDFtoImage.SonarCloud.slnf --verbosity detailed" -f xml -o "coverage.xml" - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/githubpages.yml b/.github/workflows/githubpages.yml index 5b80bcfb..e3072c31 100644 --- a/.github/workflows/githubpages.yml +++ b/.github/workflows/githubpages.yml @@ -17,12 +17,12 @@ jobs: uses: actions/checkout@main with: fetch-depth: 0 - - name: Setup .NET 8 + - name: Setup .NET uses: actions/setup-dotnet@main with: dotnet-version: 8.x - - name: Setup .NET workload android - run: dotnet workload install android + - name: Setup .NET workload maui-android + run: dotnet workload install maui-android - name: Setup .NET workload wasm-tools run: dotnet workload install wasm-tools - name: Update relative paths @@ -94,4 +94,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@main + uses: actions/deploy-pages@main \ No newline at end of file diff --git a/.github/workflows/githubpages_staging.yml b/.github/workflows/githubpages_staging.yml index bfa510e9..0b8defcb 100644 --- a/.github/workflows/githubpages_staging.yml +++ b/.github/workflows/githubpages_staging.yml @@ -18,12 +18,12 @@ jobs: uses: actions/checkout@main with: fetch-depth: 0 - - name: Setup .NET 8 + - name: Setup .NET uses: actions/setup-dotnet@main with: dotnet-version: 8.x - - name: Setup .NET workload android - run: dotnet workload install android + - name: Setup .NET workload maui-android + run: dotnet workload install maui-android - name: Setup .NET workload wasm-tools run: dotnet workload install wasm-tools - name: Update relative paths @@ -79,6 +79,10 @@ jobs: needs: publish runs-on: ubuntu-latest + concurrency: + group: "pages-stating" + cancel-in-progress: true + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: pages: write # to deploy to Pages @@ -87,10 +91,6 @@ jobs: environment: name: github-pages-staging url: ${{ steps.deployment.outputs.page_url }} - - concurrency: - group: "pages" - cancel-in-progress: true steps: - name: Deploy to GitHub Pages diff --git a/src/Console/Console.csproj b/src/Console/Console.csproj index 08baa5a0..4696ea97 100644 --- a/src/Console/Console.csproj +++ b/src/Console/Console.csproj @@ -7,7 +7,7 @@ PDFtoImage.Console PDFtoImage.Console PDFtoImage.Console.Program - 4.0.2 + 4.1.0 Debug;Release;ReleaseSigned @@ -17,7 +17,7 @@ enable strict nullable - CA1416 + CS0618,CA1416 diff --git a/src/FrameworkTests/AotConsole/Program.cs b/src/FrameworkTests/AotConsole/Program.cs index 43ef85a7..32397924 100644 --- a/src/FrameworkTests/AotConsole/Program.cs +++ b/src/FrameworkTests/AotConsole/Program.cs @@ -9,7 +9,7 @@ public static void Main() { Directory.SetCurrentDirectory(Path.GetDirectoryName(AppContext.BaseDirectory)!); using var input = new FileStream("SocialPreview.pdf", FileMode.Open, FileAccess.Read); - using var bitmap = PDFtoImage.Conversion.ToImage(input); + using var bitmap = PDFtoImage.Conversion.ToImage(input, 0); Console.WriteLine($"SocialPreview.pdf size: {bitmap.Width}x{bitmap.Height}"); diff --git a/src/FrameworkTests/AspNet/Properties/AssemblyInfo.cs b/src/FrameworkTests/AspNet/Properties/AssemblyInfo.cs index 08521cd1..3fdca9a7 100644 --- a/src/FrameworkTests/AspNet/Properties/AssemblyInfo.cs +++ b/src/FrameworkTests/AspNet/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden diff --git a/src/FrameworkTests/AspNetCore/Program.cs b/src/FrameworkTests/AspNetCore/Program.cs index 41582281..4813e2a9 100644 --- a/src/FrameworkTests/AspNetCore/Program.cs +++ b/src/FrameworkTests/AspNetCore/Program.cs @@ -23,7 +23,7 @@ private static string GetOutput() using var input = new FileStream(Path.Combine(_hostingEnvironment!.WebRootPath, "SocialPreview.pdf"), FileMode.Open, FileAccess.Read); #pragma warning disable CA1416 // Validate platform compatibility - using var bitmap = PDFtoImage.Conversion.ToImage(input); + using var bitmap = PDFtoImage.Conversion.ToImage(input, 0); #pragma warning restore CA1416 // Validate platform compatibility return $"SocialPreview.pdf size: {bitmap.Width}x{bitmap.Height}"; diff --git a/src/FrameworkTests/MauiApp/MainPage.xaml.cs b/src/FrameworkTests/MauiApp/MainPage.xaml.cs index 6a6a6ef3..79029ded 100644 --- a/src/FrameworkTests/MauiApp/MainPage.xaml.cs +++ b/src/FrameworkTests/MauiApp/MainPage.xaml.cs @@ -15,7 +15,7 @@ private async void OnCounterClicked(object sender, EventArgs e) using var ms = new MemoryStream(); input.CopyTo(ms); - using var bitmap = PDFtoImage.Conversion.ToImage(ms); + using var bitmap = PDFtoImage.Conversion.ToImage(ms, 0); OutputLabel.Text = $"SocialPreview.pdf size: {bitmap.Width}x{bitmap.Height}"; } diff --git a/src/FrameworkTests/MauiApp/MauiApp.csproj b/src/FrameworkTests/MauiApp/MauiApp.csproj index 99aceb0e..485af552 100644 --- a/src/FrameworkTests/MauiApp/MauiApp.csproj +++ b/src/FrameworkTests/MauiApp/MauiApp.csproj @@ -50,8 +50,8 @@ - - + + diff --git a/src/FrameworkTests/MauiApp/Platforms/Android/MainActivity.cs b/src/FrameworkTests/MauiApp/Platforms/Android/MainActivity.cs index b6eea2e1..2e4d8cf0 100644 --- a/src/FrameworkTests/MauiApp/Platforms/Android/MainActivity.cs +++ b/src/FrameworkTests/MauiApp/Platforms/Android/MainActivity.cs @@ -1,6 +1,5 @@ using Android.App; using Android.Content.PM; -using Android.OS; namespace PDFtoImage.FrameworkTests.MauiApp { diff --git a/src/FrameworkTests/MauiApp/Platforms/Windows/App.xaml.cs b/src/FrameworkTests/MauiApp/Platforms/Windows/App.xaml.cs index 050d3f27..9577dc3b 100644 --- a/src/FrameworkTests/MauiApp/Platforms/Windows/App.xaml.cs +++ b/src/FrameworkTests/MauiApp/Platforms/Windows/App.xaml.cs @@ -1,6 +1,4 @@ -using Microsoft.UI.Xaml; - -// To learn more about WinUI, the WinUI project structure, +// To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. namespace PDFtoImage.FrameworkTests.MauiApp.WinUI diff --git a/src/FrameworkTests/Uwp/Properties/AssemblyInfo.cs b/src/FrameworkTests/Uwp/Properties/AssemblyInfo.cs index b815ec83..b0ea5c12 100644 --- a/src/FrameworkTests/Uwp/Properties/AssemblyInfo.cs +++ b/src/FrameworkTests/Uwp/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden diff --git a/src/PDFtoImage.Build.slnf b/src/PDFtoImage.Build.slnf index 4ce72465..23d338c1 100644 --- a/src/PDFtoImage.Build.slnf +++ b/src/PDFtoImage.Build.slnf @@ -6,7 +6,6 @@ "FrameworkTests\\AotConsole\\AotConsole.csproj", "FrameworkTests\\AspNetCore\\AspNetCore.csproj", "FrameworkTests\\MauiApp\\MauiApp.csproj", - "FrameworkTests\\MonoAndroid\\MonoAndroid.csproj", "FrameworkTests\\MonoConsole\\MonoConsole.csproj", "PDFtoImage\\PDFtoImage.csproj", "Tests\\Tests.csproj", diff --git a/src/PDFtoImage.sln b/src/PDFtoImage.sln index 215407df..eccad8c4 100644 --- a/src/PDFtoImage.sln +++ b/src/PDFtoImage.sln @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebConverter", "WebConverte EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FrameworkTests", "FrameworkTests", "{7BB9FE70-BACD-4FC6-B90A-B505265A66E0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoAndroid", "FrameworkTests\MonoAndroid\MonoAndroid.csproj", "{E6458852-9C48-48CE-AC1C-99374F3B3092}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp", "FrameworkTests\MauiApp\MauiApp.csproj", "{F1B387C4-5E76-4079-991A-ED6684112317}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore", "FrameworkTests\AspNetCore\AspNetCore.csproj", "{451B5027-1F18-4132-B5AF-DB752DDE91FD}" @@ -174,51 +172,6 @@ Global {EDA29F04-48E7-4823-8141-22A82CB80037}.ReleaseSigned|x64.Build.0 = Release|Any CPU {EDA29F04-48E7-4823-8141-22A82CB80037}.ReleaseSigned|x86.ActiveCfg = Release|Any CPU {EDA29F04-48E7-4823-8141-22A82CB80037}.ReleaseSigned|x86.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM.ActiveCfg = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM.Build.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM.Deploy.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM64.Build.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|ARM64.Deploy.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x64.ActiveCfg = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x64.Build.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x64.Deploy.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x86.ActiveCfg = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x86.Build.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Debug|x86.Deploy.0 = Debug|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|Any CPU.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|Any CPU.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM64.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM64.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|ARM64.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x64.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x64.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x64.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x86.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x86.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.Release|x86.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|Any CPU.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM64.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM64.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|ARM64.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x64.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x64.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x64.Deploy.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x86.ActiveCfg = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x86.Build.0 = Release|Any CPU - {E6458852-9C48-48CE-AC1C-99374F3B3092}.ReleaseSigned|x86.Deploy.0 = Release|Any CPU {F1B387C4-5E76-4079-991A-ED6684112317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F1B387C4-5E76-4079-991A-ED6684112317}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1B387C4-5E76-4079-991A-ED6684112317}.Debug|Any CPU.Deploy.0 = Debug|Any CPU @@ -464,7 +417,59 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {E6458852-9C48-48CE-AC1C-99374F3B3092} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {F1B387C4-5E76-4079-991A-ED6684112317} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {451B5027-1F18-4132-B5AF-DB752DDE91FD} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {4453B6F1-0470-420A-BD2C-7BE64EE8E256} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {4559B552-D5FD-49F1-B5B7-8ADE803FD6E0} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {B5661A01-5093-4441-A22A-D51C88267F2F} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {4CABB057-5816-486B-A52F-E0BBAB456431} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + {78BA516B-2BB8-7C77-CF97-A656E70436D4} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D6C1E6C9-335A-4797-9F4E-2DEB42A9B295} + EndGlobalSection +EndGlobal +6-486B-A52F-E0BBAB456431}.ReleaseSigned|ARM64.ActiveCfg = Release|Any CPU + {4CABB057-5816-486B-A52F-E0BBAB456431}.ReleaseSigned|ARM64.Build.0 = Release|Any CPU + {4CABB057-5816-486B-A52F-E0BBAB456431}.ReleaseSigned|x64.ActiveCfg = Release|Any CPU + {4CABB057-5816-486B-A52F-E0BBAB456431}.ReleaseSigned|x64.Build.0 = Release|Any CPU + {4CABB057-5816-486B-A52F-E0BBAB456431}.ReleaseSigned|x86.ActiveCfg = Release|Any CPU + {4CABB057-5816-486B-A52F-E0BBAB456431}.ReleaseSigned|x86.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|ARM.Build.0 = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|ARM64.Build.0 = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|x64.ActiveCfg = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|x64.Build.0 = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|x86.ActiveCfg = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Debug|x86.Build.0 = Debug|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|Any CPU.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|ARM.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|ARM.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|ARM64.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|ARM64.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|x64.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|x64.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|x86.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.Release|x86.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|ARM.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|ARM.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|ARM64.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|ARM64.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|x64.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|x64.Build.0 = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|x86.ActiveCfg = Release|Any CPU + {78BA516B-2BB8-7C77-CF97-A656E70436D4}.ReleaseSigned|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution {F1B387C4-5E76-4079-991A-ED6684112317} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} {451B5027-1F18-4132-B5AF-DB752DDE91FD} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} {4453B6F1-0470-420A-BD2C-7BE64EE8E256} = {7BB9FE70-BACD-4FC6-B90A-B505265A66E0} diff --git a/src/PDFtoImage/Conversion.Base64.cs b/src/PDFtoImage/Conversion.Base64.cs new file mode 100644 index 00000000..cf015859 --- /dev/null +++ b/src/PDFtoImage/Conversion.Base64.cs @@ -0,0 +1,301 @@ +using SkiaSharp; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; + +#if NET6_0_OR_GREATER +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +#endif + +namespace PDFtoImage +{ + /// + /// Provides methods to render PDFs into images. + /// +#if NET8_0_OR_GREATER +#pragma warning disable CA1510 // Use ArgumentNullException throw helper +#endif +#if NET6_0_OR_GREATER + [SupportedOSPlatform("Windows")] + [SupportedOSPlatform("Linux")] + [SupportedOSPlatform("macOS")] + [SupportedOSPlatform("Android31.0")] +#endif + public static partial class Conversion + { + /// + /// Returns the page count of a given PDF. + /// + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The page count of the given PDF. + public static int GetPageCount(string pdfAsBase64String, string? password = null) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return GetPageCount(Convert.FromBase64String(pdfAsBase64String), password); + } + + /// + /// Returns the sizes of all PDF pages. + /// + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The page sizes containing width and height. + public static IList GetPageSizes(string pdfAsBase64String, string? password = null) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return GetPageSizes(Convert.FromBase64String(pdfAsBase64String), password); + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(string pdfAsBase64String, string? password = null, RenderOptions options = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + foreach (var image in ToImages(Convert.FromBase64String(pdfAsBase64String), password, options)) + { + yield return image; + } + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(string pdfAsBase64String, IEnumerable pages, string? password = null, RenderOptions options = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + foreach (var image in ToImages(Convert.FromBase64String(pdfAsBase64String), pages, password, options)) + { + yield return image; + } + } + +#if NET6_0_OR_GREATER + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF encoded as Base64. + /// The specific page to query the size for. + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. + public static SizeF GetPageSize(string pdfAsBase64String, Index page, string? password = null) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return GetPageSize(Convert.FromBase64String(pdfAsBase64String), page, password); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(string imageFilename, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(Stream imageStream, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(string imageFilename, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(Stream imageStream, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(string imageFilename, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(Stream imageStream, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsBase64String, page, password, options); + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF encoded as Base64. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The converted PDF page as an image. + public static SKBitmap ToImage(string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return ToImage(Convert.FromBase64String(pdfAsBase64String), page, password, options); + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(string pdfAsBase64String, Range pages, string? password = null, RenderOptions options = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + foreach (var image in ToImages(Convert.FromBase64String(pdfAsBase64String), pages, password, options)) + { + yield return image; + } + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(string pdfAsBase64String, Range pages, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + await foreach (var image in ToImagesAsync(Convert.FromBase64String(pdfAsBase64String), pages, password, options, cancellationToken)) + { + yield return image; + } + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(string pdfAsBase64String, IEnumerable pages, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + await foreach (var image in ToImagesAsync(Convert.FromBase64String(pdfAsBase64String), pages, password, options, cancellationToken)) + { + yield return image; + } + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF encoded as Base64. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(string pdfAsBase64String, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + await foreach (var image in ToImagesAsync(Convert.FromBase64String(pdfAsBase64String), password, options, cancellationToken)) + { + yield return image; + } + } + + internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + if (imageFilename == null) + throw new ArgumentNullException(nameof(imageFilename)); + + using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfAsBase64String, page, password, options); + } + + internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, string pdfAsBase64String, Index page, string? password = null, RenderOptions options = default) + { + if (imageStream == null) + throw new ArgumentNullException(nameof(imageStream)); + + using var bitmap = ToImage(pdfAsBase64String, page, password, options); + bitmap.Encode(imageStream, format, 100); + } +#endif + } +} \ No newline at end of file diff --git a/src/PDFtoImage/Conversion.ByteArray.cs b/src/PDFtoImage/Conversion.ByteArray.cs new file mode 100644 index 00000000..52c5820e --- /dev/null +++ b/src/PDFtoImage/Conversion.ByteArray.cs @@ -0,0 +1,331 @@ +using SkiaSharp; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; + +#if NET6_0_OR_GREATER +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +#endif + +namespace PDFtoImage +{ + /// + /// Provides methods to render PDFs into images. + /// +#if NET8_0_OR_GREATER +#pragma warning disable CA1510 // Use ArgumentNullException throw helper +#endif +#if NET6_0_OR_GREATER + [SupportedOSPlatform("Windows")] + [SupportedOSPlatform("Linux")] + [SupportedOSPlatform("macOS")] + [SupportedOSPlatform("Android31.0")] +#endif + public static partial class Conversion + { + /// + /// Returns the page count of a given PDF. + /// + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The page count of the given PDF. + public static int GetPageCount(byte[] pdfAsByteArray, string? password = null) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return GetPageCount(pdfStream, false, password); + } + + /// + /// Returns the sizes of all PDF pages. + /// + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The page sizes containing width and height. + public static IList GetPageSizes(byte[] pdfAsByteArray, string? password = null) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return GetPageSizes(pdfStream, false, password); + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(byte[] pdfAsByteArray, string? password = null, RenderOptions options = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + foreach (var image in ToImages(pdfStream, false, password, options)) + { + yield return image; + } + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(byte[] pdfAsByteArray, IEnumerable pages, string? password = null, RenderOptions options = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + foreach (var image in ToImages(pdfStream, pages, false, password, options)) + { + yield return image; + } + } + +#if NET6_0_OR_GREATER + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF as a byte array. + /// The specific page to query the size for. + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. + public static SizeF GetPageSize(byte[] pdfAsByteArray, Index page, string? password = null) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return GetPageSize(pdfStream, page, false, password); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(string imageFilename, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(Stream imageStream, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(string imageFilename, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(Stream imageStream, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(string imageFilename, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(Stream imageStream, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsByteArray, page, password, options); + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF as a byte array. + /// The specific page to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The converted PDF page as an image. + public static SKBitmap ToImage(byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return ToImage(pdfStream, page, false, password, options); + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(byte[] pdfAsByteArray, Range pages, string? password = null, RenderOptions options = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + foreach (var image in ToImages(pdfStream, pages, false, password, options)) + { + yield return image; + } + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(byte[] pdfAsByteArray, Range pages, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + await foreach (var image in ToImagesAsync(pdfStream, pages, false, password, options, cancellationToken)) + { + yield return image; + } + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The specific pages to be converted. + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(byte[] pdfAsByteArray, IEnumerable pages, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + await foreach (var image in ToImagesAsync(pdfStream, pages, false, password, options, cancellationToken)) + { + yield return image; + } + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF as a byte array. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(byte[] pdfAsByteArray, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + await foreach (var image in ToImagesAsync(pdfStream, false, password, options, cancellationToken)) + { + yield return image; + } + } + + internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + if (imageFilename == null) + throw new ArgumentNullException(nameof(imageFilename)); + + using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfAsByteArray, page, password, options); + } + + internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, byte[] pdfAsByteArray, Index page, string? password = null, RenderOptions options = default) + { + if (imageStream == null) + throw new ArgumentNullException(nameof(imageStream)); + + using var bitmap = ToImage(pdfAsByteArray, page, password, options); + bitmap.Encode(imageStream, format, 100); + } +#endif + } +} \ No newline at end of file diff --git a/src/PDFtoImage/Conversion.Deprecated.cs b/src/PDFtoImage/Conversion.Deprecated.cs new file mode 100644 index 00000000..3654aa76 --- /dev/null +++ b/src/PDFtoImage/Conversion.Deprecated.cs @@ -0,0 +1,510 @@ +using PDFtoImage.Internals; +using SkiaSharp; +using System; +using System.Drawing; +using System.IO; +using System.Linq; +#if NET6_0_OR_GREATER +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +#endif + +namespace PDFtoImage +{ + /// + /// Provides methods to render PDFs into images. + /// +#if NET8_0_OR_GREATER +#pragma warning disable CA1510 // Use ArgumentNullException throw helper +#endif +#if NET6_0_OR_GREATER + [SupportedOSPlatform("Windows")] + [SupportedOSPlatform("Linux")] + [SupportedOSPlatform("macOS")] + [SupportedOSPlatform("Android31.0")] +#endif + public static partial class Conversion + { + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsBase64String, password, page, options); + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF encoded as Base64. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. + /// The converted PDF page as an image. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use ToImage with a System.Index instead.")] +#endif + public static SKBitmap ToImage(string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return ToImage(Convert.FromBase64String(pdfAsBase64String), password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsByteArray, password, page, options); + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF as a byte array. + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. + /// The converted PDF page as an image. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use ToImage with a System.Index instead.")] +#endif + public static SKBitmap ToImage(byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return ToImage(pdfStream, false, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveJpeg with a System.Index instead.")] +#endif + public static void SaveJpeg(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SavePng with a System.Index instead.")] +#endif + public static void SavePng(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveWebp with a System.Index instead.")] +#endif + public static void SaveWebp(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfStream, leaveOpen, password, page, options); + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The specific page to be converted. + /// Additional options for PDF rendering. + /// The rendered PDF page as an image. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use ToImage with a System.Index instead.")] +#endif + public static SKBitmap ToImage(Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + return ToImagesImpl(pdfStream, leaveOpen, password, options, [page]).First(); + } + + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF encoded as Base64. + /// The specific page to query the size for. + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use GetPageSize with a System.Index instead.")] +#endif + public static SizeF GetPageSize(string pdfAsBase64String, int page, string? password = null) + { + if (pdfAsBase64String == null) + throw new ArgumentNullException(nameof(pdfAsBase64String)); + + return GetPageSize(Convert.FromBase64String(pdfAsBase64String), page, password); + } + + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF as a byte array. + /// The specific page to query the size for. + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use GetPageSize with a System.Index instead.")] +#endif + public static SizeF GetPageSize(byte[] pdfAsByteArray, int page, string? password = null) + { + if (pdfAsByteArray == null) + throw new ArgumentNullException(nameof(pdfAsByteArray)); + + // Base64 string -> byte[] -> MemoryStream + using var pdfStream = new MemoryStream(pdfAsByteArray, false); + + return GetPageSize(pdfStream, false, page, password); + } + + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The specific page to query the size for. + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use GetPageSize with a System.Index instead.")] +#endif + public static SizeF GetPageSize(Stream pdfStream, bool leaveOpen = false, int page = 0, string? password = null) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + if (page < 0) + throw new ArgumentOutOfRangeException(nameof(page), "The page number must be 0 or greater."); + + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + return pdfDocument.PageSizes[page]; + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(string filename, SKEncodedImageFormat format, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + using var fileStream = new FileStream(filename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfStream, leaveOpen, password, page, options); + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(Stream stream, SKEncodedImageFormat format, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + { + using var bitmap = ToImage(pdfStream, leaveOpen, password, page, options); + bitmap.Encode(stream, format, 100); + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + if (imageFilename == null) + throw new ArgumentNullException(nameof(imageFilename)); + + using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfAsByteArray, password, page, options); + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) + { + if (imageStream == null) + throw new ArgumentNullException(nameof(imageStream)); + + using var bitmap = ToImage(pdfAsByteArray, password, page, options); + bitmap.Encode(imageStream, format, 100); + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + if (imageFilename == null) + throw new ArgumentNullException(nameof(imageFilename)); + + using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfAsBase64String, password, page, options); + } + +#if NET6_0_OR_GREATER + [Obsolete("This method is deprecated and will be removed in a future release. Use SaveImpl with a System.Index instead.")] +#endif + internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) + { + if (imageStream == null) + throw new ArgumentNullException(nameof(imageStream)); + + using var bitmap = ToImage(pdfAsBase64String, password, page, options); + bitmap.Encode(imageStream, format, 100); + } + } +} \ No newline at end of file diff --git a/src/PDFtoImage/Conversion.Stream.cs b/src/PDFtoImage/Conversion.Stream.cs new file mode 100644 index 00000000..b829d48f --- /dev/null +++ b/src/PDFtoImage/Conversion.Stream.cs @@ -0,0 +1,362 @@ +using PDFtoImage.Internals; +using SkiaSharp; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +#if NET6_0_OR_GREATER +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +#endif + +namespace PDFtoImage +{ + /// + /// Provides methods to render PDFs into images. + /// +#if NET8_0_OR_GREATER +#pragma warning disable CA1510 // Use ArgumentNullException throw helper +#endif +#if NET6_0_OR_GREATER + [SupportedOSPlatform("Windows")] + [SupportedOSPlatform("Linux")] + [SupportedOSPlatform("macOS")] + [SupportedOSPlatform("Android31.0")] +#endif + public static partial class Conversion + { + /// + /// Returns the page count of a given PDF. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The page count of the given PDF. + public static int GetPageCount(Stream pdfStream, bool leaveOpen = false, string? password = null) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + return pdfDocument.PageSizes.Count; + } + + /// + /// Returns the sizes of all PDF pages. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The page sizes containing width and height. + public static IList GetPageSizes(Stream pdfStream, bool leaveOpen = false, string? password = null) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + return pdfDocument.PageSizes.ToList().AsReadOnly(); + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(Stream pdfStream, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + return ToImagesImpl(pdfStream, leaveOpen, password, options, null); + } + + /// + /// Renders a selection of pages of a given PDF into images. + /// + /// The PDF as a stream. + /// The specific pages to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(Stream pdfStream, IEnumerable pages, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + // Stream -> Internals.PdfDocument + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + + if (pages.Any(p => p >= pageCount)) + throw new ArgumentOutOfRangeException(nameof(pages), $"The page numbers must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + foreach (var bitmap in ToImagesImpl(pdfStream, leaveOpen, password, options, pages)) + { + yield return bitmap; + } + } + +#if NET6_0_OR_GREATER + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image file path. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(string imageFilename, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a JPEG. + /// + /// The output image stream. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveJpeg(Stream imageStream, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image file path. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(string imageFilename, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a PNG. + /// + /// The output image stream. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SavePng(Stream imageStream, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image file path. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(string imageFilename, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Renders a single page of a given PDF and saves it as a bitmap. + /// + /// The output image stream. + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + public static void SaveWebp(Stream imageStream, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfStream, page, leaveOpen, password, options); + } + + /// + /// Returns the PDF page size for a given page number. + /// + /// The PDF as a stream. + /// The specific page to query the size for. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// The page size containing width and height. + public static SizeF GetPageSize(Stream pdfStream, Index page, bool leaveOpen = false, string? password = null) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + var offset = page.GetOffset(pageCount); + + if (offset >= pageCount) + throw new ArgumentOutOfRangeException(nameof(page), $"The page number must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + return pdfDocument.PageSizes[offset]; + } + + /// + /// Renders a single page of a given PDF into an image. + /// + /// The PDF as a stream. + /// The specific page to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF page as an image. + public static SKBitmap ToImage(Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + // Stream -> Internals.PdfDocument + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + var offset = page.GetOffset(pageCount); + + if (offset >= pageCount) + throw new ArgumentOutOfRangeException(nameof(page), $"The page number must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + return ToImagesImpl(pdfDocument, options, [offset]).First(); + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF as a stream. + /// The specific pages to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The rendered PDF pages as images. + public static IEnumerable ToImages(Stream pdfStream, Range pages, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + // Stream -> Internals.PdfDocument + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + var (offset, length) = pages.GetOffsetAndLength(pageCount); + + if (offset + length > pageCount) + throw new ArgumentOutOfRangeException(nameof(pages), $"The page numbers must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + var pageNumbers = Enumerable.Range(offset, length); + + foreach (var bitmap in ToImagesImpl(pdfStream, leaveOpen, password, options, pageNumbers)) + { + yield return bitmap; + } + } + + /// + /// Renders a range of pages of a given PDF into images. + /// + /// The PDF as a stream. + /// The specific pages to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, Range pages, bool leaveOpen = false, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + // Stream -> Internals.PdfDocument + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + var (offset, length) = pages.GetOffsetAndLength(pageCount); + + if (offset + length > pageCount) + throw new ArgumentOutOfRangeException(nameof(pages), $"The page numbers must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + var pageNumbers = Enumerable.Range(offset, length); + + await foreach (var bitmap in ToImagesImplAsync(pdfStream, leaveOpen, password, options, pageNumbers, cancellationToken)) + { + yield return bitmap; + } + } + + /// + /// Renders a selection of pages of a given PDF into images. + /// + /// The PDF as a stream. + /// The specific pages to be converted. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, IEnumerable pages, bool leaveOpen = false, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + if (pdfStream == null) + throw new ArgumentNullException(nameof(pdfStream)); + + // Stream -> Internals.PdfDocument + using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); + + var pageCount = pdfDocument.PageSizes.Count; + + if (pages.Any(p => p >= pageCount)) + throw new ArgumentOutOfRangeException(nameof(pages), $"The page numbers must be between 0 and {pageCount - 1}. The PDF has {pageCount} pages in total."); + + await foreach (var bitmap in ToImagesImplAsync(pdfStream, leaveOpen, password, options, pages, cancellationToken)) + { + yield return bitmap; + } + } + + /// + /// Renders all pages of a given PDF into images. + /// + /// The PDF as a stream. + /// to leave the open after the PDF document is loaded; otherwise, . + /// The password for opening the PDF. Use if no password is needed. + /// Additional options for PDF rendering. + /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). + /// The rendered PDF pages as images. + public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, bool leaveOpen = false, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + await foreach (var bitmap in ToImagesImplAsync(pdfStream, leaveOpen, password, options, null, cancellationToken)) + { + yield return bitmap; + } + } + + internal static void SaveImpl(string filename, SKEncodedImageFormat format, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + using var fileStream = new FileStream(filename, FileMode.Create, FileAccess.Write); + SaveImpl(fileStream, format, pdfStream, page, leaveOpen, password, options); + } + + internal static void SaveImpl(Stream stream, SKEncodedImageFormat format, Stream pdfStream, Index page, bool leaveOpen = false, string? password = null, RenderOptions options = default) + { + using var bitmap = ToImage(pdfStream, page, leaveOpen, password, options); + bitmap.Encode(stream, format, 100); + } +#endif + } +} \ No newline at end of file diff --git a/src/PDFtoImage/Conversion.cs b/src/PDFtoImage/Conversion.cs index 28dd7df6..76ad4fdc 100644 --- a/src/PDFtoImage/Conversion.cs +++ b/src/PDFtoImage/Conversion.cs @@ -2,13 +2,14 @@ using SkiaSharp; using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Linq; +#if NET6_0_OR_GREATER using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; +#endif namespace PDFtoImage { @@ -24,540 +25,38 @@ namespace PDFtoImage [SupportedOSPlatform("macOS")] [SupportedOSPlatform("Android31.0")] #endif - public static class Conversion + public static partial class Conversion { - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image file path. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image stream. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image file path. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image stream. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image file path. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Jpeg, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a JPEG. - /// - /// The output image stream. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveJpeg(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Jpeg, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image file path. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image stream. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image file path. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image stream. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image file path. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Png, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a PNG. - /// - /// The output image stream. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SavePng(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Png, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image file path. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(string imageFilename, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image stream. - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(Stream imageStream, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsBase64String, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image file path. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(string imageFilename, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image stream. - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(Stream imageStream, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfAsByteArray, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image file path. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(string imageFilename, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageFilename, SKEncodedImageFormat.Webp, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF and saves it as a bitmap. - /// - /// The output image stream. - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - public static void SaveWebp(Stream imageStream, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - SaveImpl(imageStream, SKEncodedImageFormat.Webp, pdfStream, leaveOpen, password, page, options); - } - - /// - /// Renders a single page of a given PDF into an image. - /// - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - /// The converted PDF page as an image. - public static SKBitmap ToImage(string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); - - return ToImage(Convert.FromBase64String(pdfAsBase64String), password, page, options); - } - - /// - /// Renders a single page of a given PDF into an image. - /// - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - /// The converted PDF page as an image. - public static SKBitmap ToImage( - byte[] pdfAsByteArray, - string? password = null, - int page = 0, - RenderOptions options = default) - { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); - - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); - - return ToImage(pdfStream, false, password, page, options); - } - - /// - /// Renders a single page of a given PDF into an image. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The specific page to be converted. - /// Additional options for PDF rendering. - /// The rendered PDF page as an image. - public static SKBitmap ToImage(Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) + internal static IEnumerable ToImagesImpl(Stream pdfStream, bool leaveOpen, string? password, RenderOptions options, IEnumerable? pages) { if (pdfStream == null) throw new ArgumentNullException(nameof(pdfStream)); - if (page < 0) - throw new ArgumentOutOfRangeException(nameof(page), "The page number must be 0 or greater."); - - if (options == default) - options = new(); - - NativeMethods.FPDF renderFlags = default; - - if (options.WithAnnotations) - renderFlags |= NativeMethods.FPDF.ANNOT; - - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Text)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHTEXT; - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Images)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHIMAGE; - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Paths)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHPATH; - // Stream -> Internals.PdfDocument using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); - if (page >= pdfDocument.PageSizes.Count) - throw new ArgumentOutOfRangeException(nameof(page), $"The page number {page} does not exist. Highest page number available is {pdfDocument.PageSizes.Count - 1}."); - - // Internals.PdfDocument -> Image - return pdfDocument.Render( - page, - options.Width, - options.Height, - options.Dpi, - options.Dpi, - options.Rotation, - renderFlags, - options.WithFormFill, - options.BackgroundColor ?? SKColors.White, - options.Bounds, - options.UseTiling, - options.WithAspectRatio, - options.DpiRelativeToBounds); - } - - /// - /// Returns the page count of a given PDF. - /// - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The page count of the given PDF. - public static int GetPageCount(string pdfAsBase64String, string? password = null) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); - - return GetPageCount(Convert.FromBase64String(pdfAsBase64String), password); - } - - /// - /// Returns the page count of a given PDF. - /// - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The page count of the given PDF. - public static int GetPageCount(byte[] pdfAsByteArray, string? password = null) - { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); - - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); - - return GetPageCount(pdfStream, false, password); - } - - /// - /// Returns the page count of a given PDF. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The page count of the given PDF. - public static int GetPageCount(Stream pdfStream, bool leaveOpen = false, string? password = null) - { - if (pdfStream == null) - throw new ArgumentNullException(nameof(pdfStream)); - - using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); - - return pdfDocument.PageSizes.Count; - } - - /// - /// Returns the PDF page size for a given page number. - /// - /// The PDF encoded as Base64. - /// The specific page to query the size for. - /// The password for opening the PDF. Use if no password is needed. - /// The page size containing width and height. - public static SizeF GetPageSize(string pdfAsBase64String, int page, string? password = null) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); - - return GetPageSize(Convert.FromBase64String(pdfAsBase64String), page, password); - } - - /// - /// Returns the PDF page size for a given page number. - /// - /// The PDF as a byte array. - /// The specific page to query the size for. - /// The password for opening the PDF. Use if no password is needed. - /// The page size containing width and height. - public static SizeF GetPageSize(byte[] pdfAsByteArray, int page, string? password = null) - { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); - - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); - - return GetPageSize(pdfStream, false, page, password); - } - - /// - /// Returns the PDF page size for a given page number. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The specific page to query the size for. - /// The password for opening the PDF. Use if no password is needed. - /// The page size containing width and height. - public static SizeF GetPageSize(Stream pdfStream, bool leaveOpen = false, int page = 0, string? password = null) - { - if (pdfStream == null) - throw new ArgumentNullException(nameof(pdfStream)); - - if (page < 0) - throw new ArgumentOutOfRangeException(nameof(page), "The page number must be 0 or greater."); - - using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); - - return pdfDocument.PageSizes[page]; - } - - /// - /// Returns the sizes of all PDF pages. - /// - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// The page sizes containing width and height. - public static IList GetPageSizes(string pdfAsBase64String, string? password = null) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); - - return GetPageSizes(Convert.FromBase64String(pdfAsBase64String), password); - } - - /// - /// Returns the sizes of all PDF pages. - /// - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// The page sizes containing width and height. - public static IList GetPageSizes(byte[] pdfAsByteArray, string? password = null) - { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); - - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); - - return GetPageSizes(pdfStream, false, password); - } - - /// - /// Returns the sizes of all PDF pages. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// The page sizes containing width and height. - public static IList GetPageSizes(Stream pdfStream, bool leaveOpen = false, string? password = null) - { - if (pdfStream == null) - throw new ArgumentNullException(nameof(pdfStream)); - - using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); - - return pdfDocument.PageSizes.ToList().AsReadOnly(); - } - - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF encoded as Base64. - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static IEnumerable ToImages(string pdfAsBase64String, string? password = null, RenderOptions options = default) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); - - foreach (var image in ToImages(Convert.FromBase64String(pdfAsBase64String), password, options)) + foreach (var bitmap in ToImagesImpl(pdfDocument, options, pages)) { - yield return image; + yield return bitmap; } } - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF as a byte array. - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static IEnumerable ToImages(byte[] pdfAsByteArray, string? password = null, RenderOptions options = default) + internal static IEnumerable ToImagesImpl(PdfDocument pdfDocument, RenderOptions options, IEnumerable? pages) { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); + if (options == default) + options = new(); - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); + pages ??= Enumerable.Range(0, pdfDocument.PageSizes.Count); - foreach (var image in ToImages(pdfStream, false, password, options)) + foreach (var page in pages.OrderBy(i => i).Distinct()) { - yield return image; + // Internals.PdfDocument -> Image + yield return RenderImpl(pdfDocument, page, GetRenderFlags(options), options); } } - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static IEnumerable ToImages(Stream pdfStream, bool leaveOpen = false, string? password = null, RenderOptions options = default) +#if NET6_0_OR_GREATER + internal static async IAsyncEnumerable ToImagesImplAsync(Stream pdfStream, bool leaveOpen, string? password, RenderOptions options, IEnumerable? pages, [EnumeratorCancellation] CancellationToken cancellationToken = default) { if (pdfStream == null) throw new ArgumentNullException(nameof(pdfStream)); @@ -565,100 +64,23 @@ public static IEnumerable ToImages(Stream pdfStream, bool leaveOpen = if (options == default) options = new(); - NativeMethods.FPDF renderFlags = default; - - if (options.WithAnnotations) - renderFlags |= NativeMethods.FPDF.ANNOT; - - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Text)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHTEXT; - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Images)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHIMAGE; - if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Paths)) - renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHPATH; - // Stream -> Internals.PdfDocument - using var pdfDocument = PdfDocument.Load(pdfStream, password, !leaveOpen); - - for (int i = 0; i < pdfDocument.PageSizes.Count; i++) - { - // Internals.PdfDocument -> Image - yield return pdfDocument.Render( - i, - options.Width, - options.Height, - options.Dpi, - options.Dpi, - options.Rotation, - renderFlags, - options.WithFormFill, - options.BackgroundColor ?? SKColors.White, - options.Bounds, - options.UseTiling, - options.WithAspectRatio, - options.DpiRelativeToBounds); - } - } + using var pdfDocument = await Task.Run(() => PdfDocument.Load(pdfStream, password, !leaveOpen), cancellationToken); -#if NET6_0_OR_GREATER - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF encoded as Base64. - /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static async IAsyncEnumerable ToImagesAsync(string pdfAsBase64String, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - if (pdfAsBase64String == null) - throw new ArgumentNullException(nameof(pdfAsBase64String)); + pages ??= Enumerable.Range(0, pdfDocument.PageSizes.Count); - await foreach (var image in ToImagesAsync(Convert.FromBase64String(pdfAsBase64String), password, options, cancellationToken)) + foreach (var page in pages.OrderBy(i => i).Distinct()) { - yield return image; - } - } - - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF as a byte array. - /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static async IAsyncEnumerable ToImagesAsync(byte[] pdfAsByteArray, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - if (pdfAsByteArray == null) - throw new ArgumentNullException(nameof(pdfAsByteArray)); - - // Base64 string -> byte[] -> MemoryStream - using var pdfStream = new MemoryStream(pdfAsByteArray, false); + cancellationToken.ThrowIfCancellationRequested(); - await foreach (var image in ToImagesAsync(pdfStream, false, password, options, cancellationToken)) - { - yield return image; + // Internals.PdfDocument -> Image + yield return await Task.Run(() => RenderImpl(pdfDocument, page, GetRenderFlags(options), options), cancellationToken); } } +#endif - /// - /// Renders all pages of a given PDF into images. - /// - /// The PDF as a stream. - /// to leave the open after the PDF document is loaded; otherwise, . - /// The cancellation token to cancel the conversion. Please note that an ongoing rendering cannot be cancelled (the next page will not be rendered though). - /// The password for opening the PDF. Use if no password is needed. - /// Additional options for PDF rendering. - /// The rendered PDF pages as images. - public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, bool leaveOpen = false, string? password = null, RenderOptions options = default, [EnumeratorCancellation] CancellationToken cancellationToken = default) + private static NativeMethods.FPDF GetRenderFlags(RenderOptions options) { - if (pdfStream == null) - throw new ArgumentNullException(nameof(pdfStream)); - - if (options == default) - options = new(); - NativeMethods.FPDF renderFlags = default; if (options.WithAnnotations) @@ -671,16 +93,13 @@ public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, b if (!options.AntiAliasing.HasFlag(PdfAntiAliasing.Paths)) renderFlags |= NativeMethods.FPDF.RENDER_NO_SMOOTHPATH; - // Stream -> Internals.PdfDocument - using var pdfDocument = await Task.Run(() => PdfDocument.Load(pdfStream, password, !leaveOpen), cancellationToken); - - for (int i = 0; i < pdfDocument.PageSizes.Count; i++) - { - cancellationToken.ThrowIfCancellationRequested(); + return renderFlags; + } - // Internals.PdfDocument -> Image - yield return await Task.Run(() => pdfDocument.Render( - i, + private static SKBitmap RenderImpl(PdfDocument pdfDocument, int page, NativeMethods.FPDF renderFlags, RenderOptions options) + { + return pdfDocument.Render( + page, options.Width, options.Height, options.Dpi, @@ -692,58 +111,7 @@ public static async IAsyncEnumerable ToImagesAsync(Stream pdfStream, b options.Bounds, options.UseTiling, options.WithAspectRatio, - options.DpiRelativeToBounds, - cancellationToken), cancellationToken); - } - } -#endif - - internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - if (imageFilename == null) - throw new ArgumentNullException(nameof(imageFilename)); - - using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); - SaveImpl(fileStream, format, pdfAsBase64String, password, page, options); - } - - internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, string pdfAsBase64String, string? password = null, int page = 0, RenderOptions options = default) - { - if (imageStream == null) - throw new ArgumentNullException(nameof(imageStream)); - - using var bitmap = ToImage(pdfAsBase64String, password, page, options); - bitmap.Encode(imageStream, format, 100); - } - - internal static void SaveImpl(string imageFilename, SKEncodedImageFormat format, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - if (imageFilename == null) - throw new ArgumentNullException(nameof(imageFilename)); - - using var fileStream = new FileStream(imageFilename, FileMode.Create, FileAccess.Write); - SaveImpl(fileStream, format, pdfAsByteArray, password, page, options); - } - - internal static void SaveImpl(string filename, SKEncodedImageFormat format, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - using var fileStream = new FileStream(filename, FileMode.Create, FileAccess.Write); - SaveImpl(fileStream, format, pdfStream, leaveOpen, password, page, options); - } - - internal static void SaveImpl(Stream imageStream, SKEncodedImageFormat format, byte[] pdfAsByteArray, string? password = null, int page = 0, RenderOptions options = default) - { - if (imageStream == null) - throw new ArgumentNullException(nameof(imageStream)); - - using var bitmap = ToImage(pdfAsByteArray, password, page, options); - bitmap.Encode(imageStream, format, 100); - } - - internal static void SaveImpl(Stream stream, SKEncodedImageFormat format, Stream pdfStream, bool leaveOpen = false, string? password = null, int page = 0, RenderOptions options = default) - { - using var bitmap = ToImage(pdfStream, leaveOpen, password, page, options); - bitmap.Encode(stream, format, 100); + options.DpiRelativeToBounds); } } } \ No newline at end of file diff --git a/src/PDFtoImage/Internals/IsExternalInit.cs b/src/PDFtoImage/Internals/IsExternalInit.cs index 09570066..6710a913 100644 --- a/src/PDFtoImage/Internals/IsExternalInit.cs +++ b/src/PDFtoImage/Internals/IsExternalInit.cs @@ -1,4 +1,4 @@ -#if NETSTANDARD || MONOANDROID || NETFRAMEWORK +#if NETSTANDARD || NETFRAMEWORK namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } diff --git a/src/PDFtoImage/PDFtoImage.csproj b/src/PDFtoImage/PDFtoImage.csproj index 5c087191..6ce2b7a5 100644 --- a/src/PDFtoImage/PDFtoImage.csproj +++ b/src/PDFtoImage/PDFtoImage.csproj @@ -1,7 +1,7 @@ - + - net462;net471;net481;net6.0;net7.0;net7.0-android;net8.0;net8.0-android;monoandroid10.0;netstandard2.0 + net462;net471;net481;net6.0;net7.0;net8.0;net8.0-android;netstandard2.0 PDFtoImage PDFtoImage true @@ -14,7 +14,7 @@ - 4.0.2 + 4.1.0 David Sungaila false @@ -23,8 +23,10 @@ https://github.com/sungaila/PDFtoImage https://raw.githubusercontent.com/sungaila/PDFtoImage/master/etc/Icon_128.png A .NET library to render PDF files into images. - - Added optional parameter DpiRelativeToBounds. - PDF Bitmap Image Convert Conversion C# PDFium SkiaSharp Skia PNG JPG JPEG WEBP Xamarin Android MonoAndroid MAUI wasm WebAssembly + - Added System.Index for single page conversion. + - Added System.Range for multiple page conversion. + - Added IEnumerable<int> for multiple page conversion. + PDF Bitmap Image Convert Conversion C# PDFium SkiaSharp Skia PNG JPG JPEG WEBP Xamarin Android MAUI wasm WebAssembly https://github.com/sungaila/PDFtoImage.git git true @@ -73,10 +75,10 @@ - - - - + + + + @@ -94,15 +96,15 @@ - - + + - + diff --git a/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt deleted file mode 100644 index 0f7af661..00000000 --- a/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Shipped.txt +++ /dev/null @@ -1,139 +0,0 @@ -#nullable enable -PDFtoImage.RenderOptions -PDFtoImage.RenderOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing -PDFtoImage.RenderOptions.AntiAliasing.init -> void -PDFtoImage.RenderOptions.BackgroundColor.get -> SkiaSharp.SKColor? -PDFtoImage.RenderOptions.BackgroundColor.init -> void -PDFtoImage.RenderOptions.Bounds.get -> System.Drawing.RectangleF? -PDFtoImage.RenderOptions.Bounds.init -> void -PDFtoImage.RenderOptions.Dpi.get -> int -PDFtoImage.RenderOptions.Dpi.init -> void -PDFtoImage.RenderOptions.DpiRelativeToBounds.get -> bool -PDFtoImage.RenderOptions.DpiRelativeToBounds.init -> void -PDFtoImage.RenderOptions.Height.get -> int? -PDFtoImage.RenderOptions.Height.init -> void -PDFtoImage.RenderOptions.RenderOptions() -> void -PDFtoImage.RenderOptions.RenderOptions(int Dpi = 300, 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 -PDFtoImage.RenderOptions.Rotation.get -> PDFtoImage.PdfRotation -PDFtoImage.RenderOptions.Rotation.init -> void -PDFtoImage.RenderOptions.Width.get -> int? -PDFtoImage.RenderOptions.Width.init -> void -PDFtoImage.RenderOptions.WithAnnotations.get -> bool -PDFtoImage.RenderOptions.WithAnnotations.init -> void -PDFtoImage.RenderOptions.WithAspectRatio.get -> bool -PDFtoImage.RenderOptions.WithAspectRatio.init -> void -PDFtoImage.RenderOptions.WithFormFill.get -> bool -PDFtoImage.RenderOptions.WithFormFill.init -> void -PDFtoImage.RenderOptions.UseTiling.get -> bool -PDFtoImage.RenderOptions.UseTiling.init -> void -PDFtoImage.IRenderOptions -PDFtoImage.IRenderOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing -PDFtoImage.IRenderOptions.AntiAliasing.init -> void -PDFtoImage.IRenderOptions.BackgroundColor.get -> SkiaSharp.SKColor? -PDFtoImage.IRenderOptions.BackgroundColor.init -> void -PDFtoImage.IRenderOptions.Bounds.get -> System.Drawing.RectangleF? -PDFtoImage.IRenderOptions.Bounds.init -> void -PDFtoImage.IRenderOptions.Dpi.get -> int -PDFtoImage.IRenderOptions.Dpi.init -> void -PDFtoImage.IRenderOptions.DpiRelativeToBounds.get -> bool -PDFtoImage.IRenderOptions.DpiRelativeToBounds.init -> void -PDFtoImage.IRenderOptions.Height.get -> int? -PDFtoImage.IRenderOptions.Height.init -> void -PDFtoImage.IRenderOptions.Rotation.get -> PDFtoImage.PdfRotation -PDFtoImage.IRenderOptions.Rotation.init -> void -PDFtoImage.IRenderOptions.UseTiling.get -> bool -PDFtoImage.IRenderOptions.UseTiling.init -> void -PDFtoImage.IRenderOptions.Width.get -> int? -PDFtoImage.IRenderOptions.Width.init -> void -PDFtoImage.IRenderOptions.WithAnnotations.get -> bool -PDFtoImage.IRenderOptions.WithAnnotations.init -> void -PDFtoImage.IRenderOptions.WithAspectRatio.get -> bool -PDFtoImage.IRenderOptions.WithAspectRatio.init -> void -PDFtoImage.IRenderOptions.WithFormFill.get -> bool -PDFtoImage.IRenderOptions.WithFormFill.init -> void -PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.None = 0 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Text = 1 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Images = 2 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Paths = 4 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.All = PDFtoImage.PdfAntiAliasing.Text | PDFtoImage.PdfAntiAliasing.Images | PDFtoImage.PdfAntiAliasing.Paths -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate0 = 0 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate180 = 2 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate270 = 3 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate90 = 1 -> PDFtoImage.PdfRotation -PDFtoImage.Exceptions.PdfCannotOpenFileException -PDFtoImage.Exceptions.PdfCannotOpenFileException.PdfCannotOpenFileException() -> void -PDFtoImage.Exceptions.PdfException -PDFtoImage.Exceptions.PdfException.PdfException(string! message) -> void -PDFtoImage.Exceptions.PdfInvalidFormatException -PDFtoImage.Exceptions.PdfInvalidFormatException.PdfInvalidFormatException() -> void -PDFtoImage.Exceptions.PdfPageNotFoundException -PDFtoImage.Exceptions.PdfPageNotFoundException.PdfPageNotFoundException() -> void -PDFtoImage.Exceptions.PdfPasswordProtectedException -PDFtoImage.Exceptions.PdfPasswordProtectedException.PdfPasswordProtectedException() -> void -PDFtoImage.Exceptions.PdfUnknownException -PDFtoImage.Exceptions.PdfUnknownException.PdfUnknownException() -> void -PDFtoImage.Exceptions.PdfUnsupportedSecuritySchemeException -PDFtoImage.Exceptions.PdfUnsupportedSecuritySchemeException.PdfUnsupportedSecuritySchemeException() -> void -PDFtoImage.Compatibility.Conversion -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.ToImage(byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(string! pdfAsBase64String, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(System.IO.Stream! pdfStream, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -PDFtoImage.Conversion -static PDFtoImage.Conversion.GetPageCount(byte[]! pdfAsByteArray, string? password = null) -> int -static PDFtoImage.Conversion.GetPageCount(string! pdfAsBase64String, string? password = null) -> int -static PDFtoImage.Conversion.GetPageCount(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null) -> int -static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, int page, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, int page, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, bool leaveOpen = false, int page = 0, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSizes(byte[]! pdfAsByteArray, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.GetPageSizes(string! pdfAsBase64String, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.GetPageSizes(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt b/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 16501054..00000000 --- a/src/PDFtoImage/PublicAPI/monoandroid10.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,4 +0,0 @@ -#nullable enable -PDFtoImage.Resource -PDFtoImage.Resource.Attribute -PDFtoImage.Resource.Resource() -> void \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net462/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net462/PublicAPI.Shipped.txt index 0f7af661..8c7ab877 100644 --- a/src/PDFtoImage/PublicAPI/net462/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net462/PublicAPI.Shipped.txt @@ -136,4 +136,7 @@ static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net471/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net471/PublicAPI.Shipped.txt index 0f7af661..8c7ab877 100644 --- a/src/PDFtoImage/PublicAPI/net471/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net471/PublicAPI.Shipped.txt @@ -136,4 +136,7 @@ static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net481/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net481/PublicAPI.Shipped.txt index 0f7af661..8c7ab877 100644 --- a/src/PDFtoImage/PublicAPI/net481/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net481/PublicAPI.Shipped.txt @@ -136,4 +136,7 @@ static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net6.0/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net6.0/PublicAPI.Shipped.txt index e242ffc8..d4a17523 100644 --- a/src/PDFtoImage/PublicAPI/net6.0/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -143,4 +143,40 @@ static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? passwor static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Shipped.txt deleted file mode 100644 index e242ffc8..00000000 --- a/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Shipped.txt +++ /dev/null @@ -1,146 +0,0 @@ -#nullable enable -PDFtoImage.RenderOptions -PDFtoImage.RenderOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing -PDFtoImage.RenderOptions.AntiAliasing.init -> void -PDFtoImage.RenderOptions.BackgroundColor.get -> SkiaSharp.SKColor? -PDFtoImage.RenderOptions.BackgroundColor.init -> void -PDFtoImage.RenderOptions.Bounds.get -> System.Drawing.RectangleF? -PDFtoImage.RenderOptions.Bounds.init -> void -PDFtoImage.RenderOptions.Dpi.get -> int -PDFtoImage.RenderOptions.Dpi.init -> void -PDFtoImage.RenderOptions.DpiRelativeToBounds.get -> bool -PDFtoImage.RenderOptions.DpiRelativeToBounds.init -> void -PDFtoImage.RenderOptions.Height.get -> int? -PDFtoImage.RenderOptions.Height.init -> void -PDFtoImage.RenderOptions.RenderOptions() -> void -PDFtoImage.RenderOptions.RenderOptions(int Dpi = 300, 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 -PDFtoImage.RenderOptions.Rotation.get -> PDFtoImage.PdfRotation -PDFtoImage.RenderOptions.Rotation.init -> void -PDFtoImage.RenderOptions.Width.get -> int? -PDFtoImage.RenderOptions.Width.init -> void -PDFtoImage.RenderOptions.WithAnnotations.get -> bool -PDFtoImage.RenderOptions.WithAnnotations.init -> void -PDFtoImage.RenderOptions.WithAspectRatio.get -> bool -PDFtoImage.RenderOptions.WithAspectRatio.init -> void -PDFtoImage.RenderOptions.WithFormFill.get -> bool -PDFtoImage.RenderOptions.WithFormFill.init -> void -PDFtoImage.RenderOptions.UseTiling.get -> bool -PDFtoImage.RenderOptions.UseTiling.init -> void -PDFtoImage.IRenderOptions -PDFtoImage.IRenderOptions.AntiAliasing.get -> PDFtoImage.PdfAntiAliasing -PDFtoImage.IRenderOptions.AntiAliasing.init -> void -PDFtoImage.IRenderOptions.BackgroundColor.get -> SkiaSharp.SKColor? -PDFtoImage.IRenderOptions.BackgroundColor.init -> void -PDFtoImage.IRenderOptions.Bounds.get -> System.Drawing.RectangleF? -PDFtoImage.IRenderOptions.Bounds.init -> void -PDFtoImage.IRenderOptions.Dpi.get -> int -PDFtoImage.IRenderOptions.Dpi.init -> void -PDFtoImage.IRenderOptions.DpiRelativeToBounds.get -> bool -PDFtoImage.IRenderOptions.DpiRelativeToBounds.init -> void -PDFtoImage.IRenderOptions.Height.get -> int? -PDFtoImage.IRenderOptions.Height.init -> void -PDFtoImage.IRenderOptions.Rotation.get -> PDFtoImage.PdfRotation -PDFtoImage.IRenderOptions.Rotation.init -> void -PDFtoImage.IRenderOptions.UseTiling.get -> bool -PDFtoImage.IRenderOptions.UseTiling.init -> void -PDFtoImage.IRenderOptions.Width.get -> int? -PDFtoImage.IRenderOptions.Width.init -> void -PDFtoImage.IRenderOptions.WithAnnotations.get -> bool -PDFtoImage.IRenderOptions.WithAnnotations.init -> void -PDFtoImage.IRenderOptions.WithAspectRatio.get -> bool -PDFtoImage.IRenderOptions.WithAspectRatio.init -> void -PDFtoImage.IRenderOptions.WithFormFill.get -> bool -PDFtoImage.IRenderOptions.WithFormFill.init -> void -PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.None = 0 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Text = 1 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Images = 2 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.Paths = 4 -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfAntiAliasing.All = PDFtoImage.PdfAntiAliasing.Text | PDFtoImage.PdfAntiAliasing.Images | PDFtoImage.PdfAntiAliasing.Paths -> PDFtoImage.PdfAntiAliasing -PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate0 = 0 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate180 = 2 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate270 = 3 -> PDFtoImage.PdfRotation -PDFtoImage.PdfRotation.Rotate90 = 1 -> PDFtoImage.PdfRotation -PDFtoImage.Exceptions.PdfCannotOpenFileException -PDFtoImage.Exceptions.PdfCannotOpenFileException.PdfCannotOpenFileException() -> void -PDFtoImage.Exceptions.PdfException -PDFtoImage.Exceptions.PdfException.PdfException(string! message) -> void -PDFtoImage.Exceptions.PdfInvalidFormatException -PDFtoImage.Exceptions.PdfInvalidFormatException.PdfInvalidFormatException() -> void -PDFtoImage.Exceptions.PdfPageNotFoundException -PDFtoImage.Exceptions.PdfPageNotFoundException.PdfPageNotFoundException() -> void -PDFtoImage.Exceptions.PdfPasswordProtectedException -PDFtoImage.Exceptions.PdfPasswordProtectedException.PdfPasswordProtectedException() -> void -PDFtoImage.Exceptions.PdfUnknownException -PDFtoImage.Exceptions.PdfUnknownException.PdfUnknownException() -> void -PDFtoImage.Exceptions.PdfUnsupportedSecuritySchemeException -PDFtoImage.Exceptions.PdfUnsupportedSecuritySchemeException.PdfUnsupportedSecuritySchemeException() -> void -PDFtoImage.Compatibility.Conversion -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> void -static PDFtoImage.Compatibility.Conversion.ToImage(byte[]! pdfAsByteArray, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(string! pdfAsBase64String, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImage(System.IO.Stream! pdfStream, string? password = null, int page = 0, int dpi = 300, 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) -> SkiaSharp.SKBitmap! -static PDFtoImage.Compatibility.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(string! pdfAsBase64String, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImages(System.IO.Stream! pdfStream, string? password = null, int dpi = 300, 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.Collections.Generic.IEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, int dpi = 300, 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.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, int dpi = 300, 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.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen, string? password = null, int dpi = 300, 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.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Compatibility.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, string? password = null, int dpi = 300, 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.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -PDFtoImage.Conversion -static PDFtoImage.Conversion.GetPageCount(byte[]! pdfAsByteArray, string? password = null) -> int -static PDFtoImage.Conversion.GetPageCount(string! pdfAsBase64String, string? password = null) -> int -static PDFtoImage.Conversion.GetPageCount(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null) -> int -static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, int page, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, int page, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, bool leaveOpen = false, int page = 0, string? password = null) -> System.Drawing.SizeF -static PDFtoImage.Conversion.GetPageSizes(byte[]! pdfAsByteArray, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.GetPageSizes(string! pdfAsBase64String, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.GetPageSizes(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null) -> System.Collections.Generic.IList! -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void -static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! -static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt b/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt deleted file mode 100644 index 16501054..00000000 --- a/src/PDFtoImage/PublicAPI/net7.0-android/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,4 +0,0 @@ -#nullable enable -PDFtoImage.Resource -PDFtoImage.Resource.Attribute -PDFtoImage.Resource.Resource() -> void \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net7.0/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net7.0/PublicAPI.Shipped.txt index e242ffc8..d4a17523 100644 --- a/src/PDFtoImage/PublicAPI/net7.0/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net7.0/PublicAPI.Shipped.txt @@ -143,4 +143,40 @@ static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? passwor static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net8.0-android/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net8.0-android/PublicAPI.Shipped.txt index e242ffc8..d4a17523 100644 --- a/src/PDFtoImage/PublicAPI/net8.0-android/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net8.0-android/PublicAPI.Shipped.txt @@ -143,4 +143,40 @@ static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? passwor static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/net8.0/PublicAPI.Shipped.txt index e242ffc8..d4a17523 100644 --- a/src/PDFtoImage/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -143,4 +143,40 @@ static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? passwor static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.GetPageSize(byte[]! pdfAsByteArray, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(string! pdfAsBase64String, System.Index page, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.GetPageSize(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null) -> System.Drawing.SizeF +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveJpeg(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SavePng(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(string! imageFilename, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.SaveWebp(System.IO.Stream! imageStream, System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> void +static PDFtoImage.Conversion.ToImage(byte[]! pdfAsByteArray, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, System.Index page, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, System.Index page, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImagesAsync(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Range pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Range pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/PDFtoImage/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/PDFtoImage/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt index 0f7af661..8c7ab877 100644 --- a/src/PDFtoImage/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/PDFtoImage/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -136,4 +136,7 @@ static PDFtoImage.Conversion.ToImage(string! pdfAsBase64String, string? password static PDFtoImage.Conversion.ToImage(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, int page = 0, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> SkiaSharp.SKBitmap! static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! -static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(byte[]! pdfAsByteArray, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(string! pdfAsBase64String, System.Collections.Generic.IEnumerable! pages, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! +static PDFtoImage.Conversion.ToImages(System.IO.Stream! pdfStream, System.Collections.Generic.IEnumerable! pages, bool leaveOpen = false, string? password = null, PDFtoImage.RenderOptions options = default(PDFtoImage.RenderOptions)) -> System.Collections.Generic.IEnumerable! \ No newline at end of file diff --git a/src/Tests/ApiTests.cs b/src/Tests/ApiTests.cs index 023ef6ad..7556a960 100644 --- a/src/Tests/ApiTests.cs +++ b/src/Tests/ApiTests.cs @@ -9,134 +9,134 @@ namespace Tests { - [TestClass] - public class ApiTests : TestBase - { - [TestMethod] - public void SaveWebpStringNullException() - { - Assert.ThrowsException(() => SaveWebp((string)null!, (string)null!)); - } - - [TestMethod] - public void SaveWebpStreamNullException() - { - Assert.ThrowsException(() => SaveWebp((Stream)null!, (string)null!)); - } - - [TestMethod] - public void SavePngStringNullException() - { - Assert.ThrowsException(() => SavePng((string)null!, (string)null!)); - } - - [TestMethod] - public void SavePngStreamNullException() - { - Assert.ThrowsException(() => SavePng((Stream)null!, (string)null!)); - } - - [TestMethod] - public void SaveJpegStringNullException() - { - Assert.ThrowsException(() => SaveJpeg((string)null!, (string)null!)); - } - - [TestMethod] - public void SaveJpegStreamNullException() - { - Assert.ThrowsException(() => SaveJpeg((Stream)null!, (string)null!)); - } - - [TestMethod] - public void ToImagePdfStringNullException() - { - Assert.ThrowsException(() => ToImage((string)null!)); - } - - [TestMethod] - public void ToImagePdfArrayNullException() - { - Assert.ThrowsException(() => ToImage((byte[])null!)); - } - - [TestMethod] - public void ToImagePdfStreamNullException() - { - Assert.ThrowsException(() => ToImage((Stream)null!)); - } - - [TestMethod] - public void GetPageCountPdfStringNullException() - { - Assert.ThrowsException(() => GetPageCount((string)null!)); - } - - [TestMethod] - public void GetPageCountPdfArrayNullException() - { - Assert.ThrowsException(() => GetPageCount((byte[])null!)); - } - - [TestMethod] - public void GetPageCountPdfStreamNullException() - { - Assert.ThrowsException(() => GetPageCount((Stream)null!)); - } - - [TestMethod] - public void GetPageSizePdfStringNullException() - { - Assert.ThrowsException(() => GetPageSize((string)null!, 0)); - } - - [TestMethod] - public void GetPageSizePdfArrayNullException() - { - Assert.ThrowsException(() => GetPageSize((byte[])null!, 0)); - } - - [TestMethod] - public void GetPageSizePdfStreamNullException() - { - Assert.ThrowsException(() => GetPageSize((Stream)null!, page:0)); - } - - [TestMethod] - public void GetPageSizesPdfStringNullException() - { - Assert.ThrowsException(() => GetPageSizes((string)null!)); - } - - [TestMethod] - public void GetPageSizesPdfArrayNullException() - { - Assert.ThrowsException(() => GetPageSizes((byte[])null!)); - } - - [TestMethod] - public void GetPageSizesPdfStreamNullException() - { - Assert.ThrowsException(() => GetPageSizes((Stream)null!)); - } - - [TestMethod] - public void ToImagesPdfStringNullException() - { - Assert.ThrowsException(() => ToImages((string)null!).ToList()); - } - - [TestMethod] - public void ToImagesPdfArrayNullException() - { - Assert.ThrowsException(() => ToImages((byte[])null!).ToList()); - } - - [TestMethod] - public void ToImagesPdfStreamNullException() - { - Assert.ThrowsException(() => ToImages((Stream)null!).ToList()); - } + [TestClass] + public class ApiTests : TestBase + { + [TestMethod] + public void SaveWebpStringNullException() + { + Assert.ThrowsException(() => SaveWebp((string)null!, (string)null!)); + } + + [TestMethod] + public void SaveWebpStreamNullException() + { + Assert.ThrowsException(() => SaveWebp((Stream)null!, (string)null!)); + } + + [TestMethod] + public void SavePngStringNullException() + { + Assert.ThrowsException(() => SavePng((string)null!, (string)null!)); + } + + [TestMethod] + public void SavePngStreamNullException() + { + Assert.ThrowsException(() => SavePng((Stream)null!, (string)null!)); + } + + [TestMethod] + public void SaveJpegStringNullException() + { + Assert.ThrowsException(() => SaveJpeg((string)null!, (string)null!)); + } + + [TestMethod] + public void SaveJpegStreamNullException() + { + Assert.ThrowsException(() => SaveJpeg((Stream)null!, (string)null!)); + } + + [TestMethod] + public void ToImagePdfStringNullException() + { + Assert.ThrowsException(() => ToImage((string)null!)); + } + + [TestMethod] + public void ToImagePdfArrayNullException() + { + Assert.ThrowsException(() => ToImage((byte[])null!)); + } + + [TestMethod] + public void ToImagePdfStreamNullException() + { + Assert.ThrowsException(() => ToImage((Stream)null!)); + } + + [TestMethod] + public void GetPageCountPdfStringNullException() + { + Assert.ThrowsException(() => GetPageCount((string)null!)); + } + + [TestMethod] + public void GetPageCountPdfArrayNullException() + { + Assert.ThrowsException(() => GetPageCount((byte[])null!)); + } + + [TestMethod] + public void GetPageCountPdfStreamNullException() + { + Assert.ThrowsException(() => GetPageCount((Stream)null!)); + } + + [TestMethod] + public void GetPageSizePdfStringNullException() + { + Assert.ThrowsException(() => GetPageSize((string)null!, 0)); + } + + [TestMethod] + public void GetPageSizePdfArrayNullException() + { + Assert.ThrowsException(() => GetPageSize((byte[])null!, 0)); + } + + [TestMethod] + public void GetPageSizePdfStreamNullException() + { + Assert.ThrowsException(() => GetPageSize((Stream)null!, page: 0)); + } + + [TestMethod] + public void GetPageSizesPdfStringNullException() + { + Assert.ThrowsException(() => GetPageSizes((string)null!)); + } + + [TestMethod] + public void GetPageSizesPdfArrayNullException() + { + Assert.ThrowsException(() => GetPageSizes((byte[])null!)); + } + + [TestMethod] + public void GetPageSizesPdfStreamNullException() + { + Assert.ThrowsException(() => GetPageSizes((Stream)null!)); + } + + [TestMethod] + public void ToImagesPdfStringNullException() + { + Assert.ThrowsException(() => ToImages((string)null!).ToList()); + } + + [TestMethod] + public void ToImagesPdfArrayNullException() + { + Assert.ThrowsException(() => ToImages((byte[])null!).ToList()); + } + + [TestMethod] + public void ToImagesPdfStreamNullException() + { + Assert.ThrowsException(() => ToImages((Stream)null!).ToList()); + } #if NET6_0_OR_GREATER [TestMethod] @@ -173,74 +173,74 @@ await Assert.ThrowsExceptionAsync(async () => } #endif - [TestMethod] - public void ToImageStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void ToImageStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void ToImageStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream, false); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } + [TestMethod] + public void ToImageStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void ToImageStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream, false); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void ToImageStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream, false); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } #if NET6_0_OR_GREATER [TestMethod] @@ -283,121 +283,121 @@ public async Task ToImagesAsyncStreamLeaveOpenTrue() } #endif - [TestMethod] - public void GetPageCountStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageCount(inputStream); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void GetPageCountStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageCount(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void GetPageCountStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageCount(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } - - [TestMethod] - public void GetPageSizeStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSize(inputStream, page: 0); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void GetPageSizeStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSize(inputStream, false, 0); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void GetPageSizeStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSize(inputStream, true, 0); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } - - [TestMethod] - public void GetPageSizesStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSizes(inputStream); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void GetPageSizesStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSizes(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void GetPageSizesStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageSizes(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } - - [TestMethod] - public void StreamMultipleCallsLeaveOpen() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - GetPageCount(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - - GetPageSizes(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - - var image1 = ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - - var image2 = ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - - Assert.IsTrue(image1.ByteCount > 0, "The rendered image should have content."); - Assert.AreEqual(image1.ByteCount, image2.ByteCount, "Both images should be equal (in byte size)."); - - GetPageSizes(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - - Assert.ThrowsException(() => GetPageCount(inputStream, false), "The stream should be closed and throw an exception."); - } - } + [TestMethod] + public void GetPageCountStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageCount(inputStream); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void GetPageCountStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageCount(inputStream, false); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void GetPageCountStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageCount(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } + + [TestMethod] + public void GetPageSizeStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSize(inputStream, page: 0); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void GetPageSizeStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSize(inputStream, false, 0); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void GetPageSizeStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSize(inputStream, true, 0); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } + + [TestMethod] + public void GetPageSizesStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSizes(inputStream); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void GetPageSizesStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSizes(inputStream, false); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void GetPageSizesStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageSizes(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } + + [TestMethod] + public void StreamMultipleCallsLeaveOpen() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + GetPageCount(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + + GetPageSizes(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + + var image1 = ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + + var image2 = ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + + Assert.IsTrue(image1.ByteCount > 0, "The rendered image should have content."); + Assert.AreEqual(image1.ByteCount, image2.ByteCount, "Both images should be equal (in byte size)."); + + GetPageSizes(inputStream, false); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + + Assert.ThrowsException(() => GetPageCount(inputStream, false), "The stream should be closed and throw an exception."); + } + } } \ No newline at end of file diff --git a/src/Tests/AspectRatioTests.cs b/src/Tests/AspectRatioTests.cs index ea01831d..5dc6ce38 100644 --- a/src/Tests/AspectRatioTests.cs +++ b/src/Tests/AspectRatioTests.cs @@ -6,408 +6,408 @@ namespace Tests { - [TestClass] - public class AspectRatioTests : TestBase - { - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] + [TestClass] + public class AspectRatioTests : TestBase + { + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] - [DataRow("SocialPreview.pdf")] - [DataRow("SocialPreview.pdf", 100, null, null)] - [DataRow("SocialPreview.pdf", 1000, null, null)] - [DataRow("SocialPreview.pdf", 2000, null, null)] - [DataRow("SocialPreview.pdf", null, 100, null)] - [DataRow("SocialPreview.pdf", null, 1000, null)] - [DataRow("SocialPreview.pdf", null, 2000, null)] - [DataRow("SocialPreview.pdf", 100, 100, null)] - [DataRow("SocialPreview.pdf", 1000, 1000, null)] - [DataRow("SocialPreview.pdf", 2000, 2000, null)] - [DataRow("SocialPreview.pdf", null, null, 96)] - [DataRow("SocialPreview.pdf", null, null, 300)] - [DataRow("SocialPreview.pdf", null, null, 600)] - [DataRow("SocialPreview.pdf", 100, null, 96)] - [DataRow("SocialPreview.pdf", 100, null, 300)] - [DataRow("SocialPreview.pdf", 100, null, 1200)] - [DataRow("SocialPreview.pdf", 1000, null, 96)] - [DataRow("SocialPreview.pdf", 1000, null, 300)] - [DataRow("SocialPreview.pdf", 1000, null, 1200)] - [DataRow("SocialPreview.pdf", 2000, null, 96)] - [DataRow("SocialPreview.pdf", 2000, null, 300)] - [DataRow("SocialPreview.pdf", 2000, null, 1200)] - [DataRow("SocialPreview.pdf", null, 100, 96)] - [DataRow("SocialPreview.pdf", null, 100, 300)] - [DataRow("SocialPreview.pdf", null, 100, 1200)] - [DataRow("SocialPreview.pdf", null, 1000, 96)] - [DataRow("SocialPreview.pdf", null, 1000, 300)] - [DataRow("SocialPreview.pdf", null, 1000, 1200)] - [DataRow("SocialPreview.pdf", null, 2000, 96)] - [DataRow("SocialPreview.pdf", null, 2000, 300)] - [DataRow("SocialPreview.pdf", null, 2000, 1200)] - [DataRow("SocialPreview.pdf", 100, 100, 96)] - [DataRow("SocialPreview.pdf", 100, 100, 300)] - [DataRow("SocialPreview.pdf", 100, 100, 1200)] - [DataRow("SocialPreview.pdf", 1000, 1000, 96)] - [DataRow("SocialPreview.pdf", 1000, 1000, 300)] - [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] - [DataRow("SocialPreview.pdf", 2000, 2000, 96)] - [DataRow("SocialPreview.pdf", 2000, 2000, 300)] - [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] + [DataRow("SocialPreview.pdf")] + [DataRow("SocialPreview.pdf", 100, null, null)] + [DataRow("SocialPreview.pdf", 1000, null, null)] + [DataRow("SocialPreview.pdf", 2000, null, null)] + [DataRow("SocialPreview.pdf", null, 100, null)] + [DataRow("SocialPreview.pdf", null, 1000, null)] + [DataRow("SocialPreview.pdf", null, 2000, null)] + [DataRow("SocialPreview.pdf", 100, 100, null)] + [DataRow("SocialPreview.pdf", 1000, 1000, null)] + [DataRow("SocialPreview.pdf", 2000, 2000, null)] + [DataRow("SocialPreview.pdf", null, null, 96)] + [DataRow("SocialPreview.pdf", null, null, 300)] + [DataRow("SocialPreview.pdf", null, null, 600)] + [DataRow("SocialPreview.pdf", 100, null, 96)] + [DataRow("SocialPreview.pdf", 100, null, 300)] + [DataRow("SocialPreview.pdf", 100, null, 1200)] + [DataRow("SocialPreview.pdf", 1000, null, 96)] + [DataRow("SocialPreview.pdf", 1000, null, 300)] + [DataRow("SocialPreview.pdf", 1000, null, 1200)] + [DataRow("SocialPreview.pdf", 2000, null, 96)] + [DataRow("SocialPreview.pdf", 2000, null, 300)] + [DataRow("SocialPreview.pdf", 2000, null, 1200)] + [DataRow("SocialPreview.pdf", null, 100, 96)] + [DataRow("SocialPreview.pdf", null, 100, 300)] + [DataRow("SocialPreview.pdf", null, 100, 1200)] + [DataRow("SocialPreview.pdf", null, 1000, 96)] + [DataRow("SocialPreview.pdf", null, 1000, 300)] + [DataRow("SocialPreview.pdf", null, 1000, 1200)] + [DataRow("SocialPreview.pdf", null, 2000, 96)] + [DataRow("SocialPreview.pdf", null, 2000, 300)] + [DataRow("SocialPreview.pdf", null, 2000, 1200)] + [DataRow("SocialPreview.pdf", 100, 100, 96)] + [DataRow("SocialPreview.pdf", 100, 100, 300)] + [DataRow("SocialPreview.pdf", 100, 100, 1200)] + [DataRow("SocialPreview.pdf", 1000, 1000, 96)] + [DataRow("SocialPreview.pdf", 1000, 1000, 300)] + [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] + [DataRow("SocialPreview.pdf", 2000, 2000, 96)] + [DataRow("SocialPreview.pdf", 2000, 2000, 300)] + [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf")] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] - public void WithoutAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false)); + [DataRow("Wikimedia_Commons_web.pdf")] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] + public void WithoutAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream = CreateOutputStream(expectedPath); - if (dpi != null) - SaveJpeg(outputStream, inputStream, options: new (Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false, Dpi: dpi.Value)); - else - SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)); + if (dpi != null) + SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false, Dpi: dpi.Value)); + else + SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] - [DataRow("SocialPreview.pdf")] - [DataRow("SocialPreview.pdf", 100, null, null)] - [DataRow("SocialPreview.pdf", 1000, null, null)] - [DataRow("SocialPreview.pdf", 2000, null, null)] - [DataRow("SocialPreview.pdf", null, 100, null)] - [DataRow("SocialPreview.pdf", null, 1000, null)] - [DataRow("SocialPreview.pdf", null, 2000, null)] - [DataRow("SocialPreview.pdf", 100, 100, null)] - [DataRow("SocialPreview.pdf", 1000, 1000, null)] - [DataRow("SocialPreview.pdf", 2000, 2000, null)] - [DataRow("SocialPreview.pdf", null, null, 96)] - [DataRow("SocialPreview.pdf", null, null, 300)] - [DataRow("SocialPreview.pdf", null, null, 600)] - [DataRow("SocialPreview.pdf", 100, null, 96)] - [DataRow("SocialPreview.pdf", 100, null, 300)] - [DataRow("SocialPreview.pdf", 100, null, 1200)] - [DataRow("SocialPreview.pdf", 1000, null, 96)] - [DataRow("SocialPreview.pdf", 1000, null, 300)] - [DataRow("SocialPreview.pdf", 1000, null, 1200)] - [DataRow("SocialPreview.pdf", 2000, null, 96)] - [DataRow("SocialPreview.pdf", 2000, null, 300)] - [DataRow("SocialPreview.pdf", 2000, null, 1200)] - [DataRow("SocialPreview.pdf", null, 100, 96)] - [DataRow("SocialPreview.pdf", null, 100, 300)] - [DataRow("SocialPreview.pdf", null, 100, 1200)] - [DataRow("SocialPreview.pdf", null, 1000, 96)] - [DataRow("SocialPreview.pdf", null, 1000, 300)] - [DataRow("SocialPreview.pdf", null, 1000, 1200)] - [DataRow("SocialPreview.pdf", null, 2000, 96)] - [DataRow("SocialPreview.pdf", null, 2000, 300)] - [DataRow("SocialPreview.pdf", null, 2000, 1200)] - [DataRow("SocialPreview.pdf", 100, 100, 96)] - [DataRow("SocialPreview.pdf", 100, 100, 300)] - [DataRow("SocialPreview.pdf", 100, 100, 1200)] - [DataRow("SocialPreview.pdf", 1000, 1000, 96)] - [DataRow("SocialPreview.pdf", 1000, 1000, 300)] - [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] - [DataRow("SocialPreview.pdf", 2000, 2000, 96)] - [DataRow("SocialPreview.pdf", 2000, 2000, 300)] - [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] + [DataRow("SocialPreview.pdf")] + [DataRow("SocialPreview.pdf", 100, null, null)] + [DataRow("SocialPreview.pdf", 1000, null, null)] + [DataRow("SocialPreview.pdf", 2000, null, null)] + [DataRow("SocialPreview.pdf", null, 100, null)] + [DataRow("SocialPreview.pdf", null, 1000, null)] + [DataRow("SocialPreview.pdf", null, 2000, null)] + [DataRow("SocialPreview.pdf", 100, 100, null)] + [DataRow("SocialPreview.pdf", 1000, 1000, null)] + [DataRow("SocialPreview.pdf", 2000, 2000, null)] + [DataRow("SocialPreview.pdf", null, null, 96)] + [DataRow("SocialPreview.pdf", null, null, 300)] + [DataRow("SocialPreview.pdf", null, null, 600)] + [DataRow("SocialPreview.pdf", 100, null, 96)] + [DataRow("SocialPreview.pdf", 100, null, 300)] + [DataRow("SocialPreview.pdf", 100, null, 1200)] + [DataRow("SocialPreview.pdf", 1000, null, 96)] + [DataRow("SocialPreview.pdf", 1000, null, 300)] + [DataRow("SocialPreview.pdf", 1000, null, 1200)] + [DataRow("SocialPreview.pdf", 2000, null, 96)] + [DataRow("SocialPreview.pdf", 2000, null, 300)] + [DataRow("SocialPreview.pdf", 2000, null, 1200)] + [DataRow("SocialPreview.pdf", null, 100, 96)] + [DataRow("SocialPreview.pdf", null, 100, 300)] + [DataRow("SocialPreview.pdf", null, 100, 1200)] + [DataRow("SocialPreview.pdf", null, 1000, 96)] + [DataRow("SocialPreview.pdf", null, 1000, 300)] + [DataRow("SocialPreview.pdf", null, 1000, 1200)] + [DataRow("SocialPreview.pdf", null, 2000, 96)] + [DataRow("SocialPreview.pdf", null, 2000, 300)] + [DataRow("SocialPreview.pdf", null, 2000, 1200)] + [DataRow("SocialPreview.pdf", 100, 100, 96)] + [DataRow("SocialPreview.pdf", 100, 100, 300)] + [DataRow("SocialPreview.pdf", 100, 100, 1200)] + [DataRow("SocialPreview.pdf", 1000, 1000, 96)] + [DataRow("SocialPreview.pdf", 1000, 1000, 300)] + [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] + [DataRow("SocialPreview.pdf", 2000, 2000, 96)] + [DataRow("SocialPreview.pdf", 2000, 2000, 300)] + [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf")] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] - public void WithAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true)); + [DataRow("Wikimedia_Commons_web.pdf")] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] + public void WithAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream = CreateOutputStream(expectedPath); - if (dpi != null) - SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true, Dpi: dpi.Value)); - else - SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)); + if (dpi != null) + SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true, Dpi: dpi.Value)); + else + SaveJpeg(outputStream, inputStream, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, false)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, true)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, true)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, true)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, true)] + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, false)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, true)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, true)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, true)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, true)] - [DataRow("SocialPreview.pdf", 100, null, false)] - [DataRow("SocialPreview.pdf", 1000, null, false)] - [DataRow("SocialPreview.pdf", 2000, null, false)] - [DataRow("SocialPreview.pdf", null, 100, false)] - [DataRow("SocialPreview.pdf", null, 1000, false)] - [DataRow("SocialPreview.pdf", null, 2000, false)] - [DataRow("SocialPreview.pdf", 100, 100, false)] - [DataRow("SocialPreview.pdf", 1000, 1000, false)] - [DataRow("SocialPreview.pdf", 2000, 2000, false)] - [DataRow("SocialPreview.pdf", 100, null, true)] - [DataRow("SocialPreview.pdf", 1000, null, true)] - [DataRow("SocialPreview.pdf", 2000, null, true)] - [DataRow("SocialPreview.pdf", null, 100, true)] - [DataRow("SocialPreview.pdf", null, 1000, true)] - [DataRow("SocialPreview.pdf", null, 2000, true)] - [DataRow("SocialPreview.pdf", 100, 100, true)] - [DataRow("SocialPreview.pdf", 1000, 1000, true)] - [DataRow("SocialPreview.pdf", 2000, 2000, true)] + [DataRow("SocialPreview.pdf", 100, null, false)] + [DataRow("SocialPreview.pdf", 1000, null, false)] + [DataRow("SocialPreview.pdf", 2000, null, false)] + [DataRow("SocialPreview.pdf", null, 100, false)] + [DataRow("SocialPreview.pdf", null, 1000, false)] + [DataRow("SocialPreview.pdf", null, 2000, false)] + [DataRow("SocialPreview.pdf", 100, 100, false)] + [DataRow("SocialPreview.pdf", 1000, 1000, false)] + [DataRow("SocialPreview.pdf", 2000, 2000, false)] + [DataRow("SocialPreview.pdf", 100, null, true)] + [DataRow("SocialPreview.pdf", 1000, null, true)] + [DataRow("SocialPreview.pdf", 2000, null, true)] + [DataRow("SocialPreview.pdf", null, 100, true)] + [DataRow("SocialPreview.pdf", null, 1000, true)] + [DataRow("SocialPreview.pdf", null, 2000, true)] + [DataRow("SocialPreview.pdf", 100, 100, true)] + [DataRow("SocialPreview.pdf", 1000, 1000, true)] + [DataRow("SocialPreview.pdf", 2000, 2000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, false)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, true)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, true)] - public void IgnoreDpi(string fileName, int? width = null, int? height = null, bool withAspectRatio = false) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio)); + [DataRow("Wikimedia_Commons_web.pdf", 100, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, false)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, true)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, true)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, true)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, true)] + public void IgnoreDpi(string fileName, int? width = null, int? height = null, bool withAspectRatio = false) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - for (int i = 72; i < 600; i += 100) - { - using var outputStream = CreateOutputStream(expectedPath); + for (int i = 72; i < 600; i += 100) + { + using var outputStream = CreateOutputStream(expectedPath); - ToImage(inputStream, true, options: new(Dpi: i, Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: withAspectRatio)).Encode(outputStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream); - } - } + ToImage(inputStream, true, options: new(Dpi: i, Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: withAspectRatio)).Encode(outputStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + CompareStreams(expectedPath, outputStream); + } + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000)] - [DataRow("SocialPreview.pdf", 100, 100)] - [DataRow("SocialPreview.pdf", 1000, 1000)] - [DataRow("SocialPreview.pdf", 2000, 2000)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000)] - public void IgnoreAspectRatio(string fileName, int width, int height) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000)] + [DataRow("SocialPreview.pdf", 100, 100)] + [DataRow("SocialPreview.pdf", 1000, 1000)] + [DataRow("SocialPreview.pdf", 2000, 2000)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000)] + public void IgnoreAspectRatio(string fileName, int width, int height) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream1 = CreateOutputStream(expectedPath); - using var outputStream2 = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream1 = CreateOutputStream(expectedPath); + using var outputStream2 = CreateOutputStream(expectedPath); - ToImage(inputStream, true, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - ToImage(inputStream, true, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, options: new(Width: width, Height: height, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream1); - CompareStreams(expectedPath, outputStream2); - } + CompareStreams(expectedPath, outputStream1); + CompareStreams(expectedPath, outputStream2); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 96)] - [DataRow("hundesteuer-anmeldung.pdf", 300)] - [DataRow("hundesteuer-anmeldung.pdf", 600)] - [DataRow("SocialPreview.pdf", 96)] - [DataRow("SocialPreview.pdf", 300)] - [DataRow("SocialPreview.pdf", 600)] - [DataRow("Wikimedia_Commons_web.pdf", 96)] - [DataRow("Wikimedia_Commons_web.pdf", 300)] - [DataRow("Wikimedia_Commons_web.pdf", 600)] - public void IgnoreAspectRatioWithDpi(string fileName, int dpi) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 96)] + [DataRow("hundesteuer-anmeldung.pdf", 300)] + [DataRow("hundesteuer-anmeldung.pdf", 600)] + [DataRow("SocialPreview.pdf", 96)] + [DataRow("SocialPreview.pdf", 300)] + [DataRow("SocialPreview.pdf", 600)] + [DataRow("Wikimedia_Commons_web.pdf", 96)] + [DataRow("Wikimedia_Commons_web.pdf", 300)] + [DataRow("Wikimedia_Commons_web.pdf", 600)] + public void IgnoreAspectRatioWithDpi(string fileName, int dpi) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream1 = CreateOutputStream(expectedPath); - using var outputStream2 = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream1 = CreateOutputStream(expectedPath); + using var outputStream2 = CreateOutputStream(expectedPath); - ToImage(inputStream, true, options: new(Dpi: dpi, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - ToImage(inputStream, true, options: new(Dpi: dpi, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, options: new(Dpi: dpi, WithAnnotations: true, WithFormFill: true, WithAspectRatio: false)).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, options: new(Dpi: dpi, WithAnnotations: true, WithFormFill: true, WithAspectRatio: true)).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream1); - CompareStreams(expectedPath, outputStream2); - } + CompareStreams(expectedPath, outputStream1); + CompareStreams(expectedPath, outputStream2); + } - private static string GetExpectedFilename(string fileName, string? fileExtension, int? width, int? height, int? dpi, bool withAspectRatio) - => $"{fileName}_w={width?.ToString() ?? "null"}_h={height?.ToString() ?? "null"}_dpi={dpi?.ToString() ?? "null"}_aspectratio={withAspectRatio}{(fileExtension != null ? $".{fileExtension}" : string.Empty)}"; - } + private static string GetExpectedFilename(string fileName, string? fileExtension, int? width, int? height, int? dpi, bool withAspectRatio) + => $"{fileName}_w={width?.ToString() ?? "null"}_h={height?.ToString() ?? "null"}_dpi={dpi?.ToString() ?? "null"}_aspectratio={withAspectRatio}{(fileExtension != null ? $".{fileExtension}" : string.Empty)}"; + } } \ No newline at end of file diff --git a/src/Tests/BatchingTests.cs b/src/Tests/BatchingTests.cs new file mode 100644 index 00000000..4a72bdb9 --- /dev/null +++ b/src/Tests/BatchingTests.cs @@ -0,0 +1,281 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using PDFtoImage.Tests; +using SkiaSharp; +using System; +using System.IO; +using System.Threading.Tasks; +using static PDFtoImage.Conversion; +using static PDFtoImage.Tests.TestUtils; + +namespace Tests +{ + [TestClass] + public class BatchingTests : TestBase + { + [TestMethod] + [DataRow(null)] + [DataRow(0)] + [DataRow(1)] + [DataRow(2)] + [DataRow(3)] + [DataRow(4)] + [DataRow(5)] + [DataRow(6)] + [DataRow(7)] + [DataRow(8)] + [DataRow(9)] + [DataRow(10)] + [DataRow(11)] + [DataRow(12)] + [DataRow(13)] + [DataRow(14)] + [DataRow(15)] + [DataRow(16)] + [DataRow(17)] + [DataRow(18)] + [DataRow(19)] + public void ToImageWithInteger(int? page) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page ?? 0}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (page == null) + SavePng(outputStream, inputStream, options: new(Dpi: 40)); + else + SavePng(outputStream, inputStream, page: page.Value, options: new(Dpi: 40)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + public void ToImagesWithSelectionOdd() + { + int[] selection = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = 0; + + foreach (var bitmap in ToImages(inputStream, selection, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{selection[i]}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } +#if NET6_0_OR_GREATER + [TestMethod] + [DataRow(0)] + [DataRow(1)] + [DataRow(2)] + [DataRow(3)] + [DataRow(4)] + [DataRow(5)] + [DataRow(6)] + [DataRow(7)] + [DataRow(8)] + [DataRow(9)] + [DataRow(10)] + [DataRow(11)] + [DataRow(12)] + [DataRow(13)] + [DataRow(14)] + [DataRow(15)] + [DataRow(16)] + [DataRow(17)] + [DataRow(18)] + [DataRow(19)] + public void ToImageWithIndex(int page) + { + var index = (Index)page; + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{index.GetOffset(20)}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + SavePng(outputStream, inputStream, index, options: new(Dpi: 40)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(0)] + [DataRow(1)] + [DataRow(2)] + [DataRow(3)] + [DataRow(4)] + [DataRow(5)] + [DataRow(6)] + [DataRow(7)] + [DataRow(8)] + [DataRow(9)] + [DataRow(10)] + [DataRow(11)] + [DataRow(12)] + [DataRow(13)] + [DataRow(14)] + [DataRow(15)] + [DataRow(16)] + [DataRow(17)] + [DataRow(18)] + [DataRow(19)] + public void ToImageWithIndexFromEnd(int page) + { + var index = new Index(page + 1, true); + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{index.GetOffset(20)}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + SavePng(outputStream, inputStream, index, options: new(Dpi: 40)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + public void ToImagesWithRangeAll() + { + var range = ..; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = range.Start.Value; + + foreach (var bitmap in ToImages(inputStream, range, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{i}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public void ToImagesWithRangeSecondHalf() + { + var range = 10..; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = range.Start.Value; + + foreach (var bitmap in ToImages(inputStream, range, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{i}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public void ToImagesWithSelectionEven() + { + int[] selection = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = 0; + + foreach (var bitmap in ToImages(inputStream, selection, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{selection[i]}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public async Task ToImagesWithRangeAllAsync() + { + var range = ..; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = range.Start.Value; + + await foreach (var bitmap in ToImagesAsync(inputStream, range, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{i}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public async Task ToImagesWithRangeSecondHalfAsync() + { + var range = 10..; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = range.Start.Value; + + await foreach (var bitmap in ToImagesAsync(inputStream, range, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{i}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public async Task ToImagesWithSelectionEvenAsync() + { + int[] selection = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = 0; + + await foreach (var bitmap in ToImagesAsync(inputStream, selection, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{selection[i]}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } + + [TestMethod] + public async Task ToImagesWithSelectionOddAsync() + { + int[] selection = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int i = 0; + + await foreach (var bitmap in ToImagesAsync(inputStream, selection, options: new(Dpi: 40))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{selection[i]}.png"); + using var outputStream = CreateOutputStream(expectedPath); + bitmap.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + i++; + } + } +#endif + } +} \ No newline at end of file diff --git a/src/Tests/ComparisonTests.cs b/src/Tests/ComparisonTests.cs index 10af967f..24a0c223 100644 --- a/src/Tests/ComparisonTests.cs +++ b/src/Tests/ComparisonTests.cs @@ -12,83 +12,83 @@ namespace Tests { - [TestClass] - public class ComparisonTests : TestBase - { - [TestMethod] - [DataRow(0, DisplayName = "Page 1")] - [DataRow(1, DisplayName = "Page 2")] - [DataRow(2, DisplayName = "Page 3")] - [DataRow(3, DisplayName = "Page 4")] - [DataRow(4, DisplayName = "Page 5")] - [DataRow(5, DisplayName = "Page 6")] - [DataRow(6, DisplayName = "Page 7")] - [DataRow(7, DisplayName = "Page 8")] - [DataRow(8, DisplayName = "Page 9")] - [DataRow(9, DisplayName = "Page 10")] - [DataRow(10, DisplayName = "Page 11")] - [DataRow(11, DisplayName = "Page 12")] - [DataRow(12, DisplayName = "Page 13")] - [DataRow(13, DisplayName = "Page 14")] - [DataRow(14, DisplayName = "Page 15")] - [DataRow(15, DisplayName = "Page 16")] - [DataRow(16, DisplayName = "Page 17")] - [DataRow(17, DisplayName = "Page 18")] - [DataRow(18, DisplayName = "Page 19")] - [DataRow(19, DisplayName = "Page 20")] - [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] - [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] - [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] - [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] - [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] - [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] - [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] - [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] - [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] - [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] - [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] - [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] - [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] - [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] - [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] - [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] - [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] - [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] - [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] - [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] - public void SaveWebpPageNumber(int page, bool withAnnotations = false) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.webp"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - SaveWebp(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(false, DisplayName = "Without annotations")] - [DataRow(true, DisplayName = "With annotations")] - public void SaveWebpPages(bool withAnnotations = false) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - - int page = 0; - - foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.webp"); - - using var outputStream = CreateOutputStream(expectedPath); - image.Encode(outputStream, SKEncodedImageFormat.Webp, 100); - - CompareStreams(expectedPath, outputStream); - - page++; - } - } + [TestClass] + public class ComparisonTests : TestBase + { + [TestMethod] + [DataRow(0, DisplayName = "Page 1")] + [DataRow(1, DisplayName = "Page 2")] + [DataRow(2, DisplayName = "Page 3")] + [DataRow(3, DisplayName = "Page 4")] + [DataRow(4, DisplayName = "Page 5")] + [DataRow(5, DisplayName = "Page 6")] + [DataRow(6, DisplayName = "Page 7")] + [DataRow(7, DisplayName = "Page 8")] + [DataRow(8, DisplayName = "Page 9")] + [DataRow(9, DisplayName = "Page 10")] + [DataRow(10, DisplayName = "Page 11")] + [DataRow(11, DisplayName = "Page 12")] + [DataRow(12, DisplayName = "Page 13")] + [DataRow(13, DisplayName = "Page 14")] + [DataRow(14, DisplayName = "Page 15")] + [DataRow(15, DisplayName = "Page 16")] + [DataRow(16, DisplayName = "Page 17")] + [DataRow(17, DisplayName = "Page 18")] + [DataRow(18, DisplayName = "Page 19")] + [DataRow(19, DisplayName = "Page 20")] + [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] + [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] + [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] + [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] + [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] + [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] + [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] + [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] + [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] + [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] + [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] + [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] + [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] + [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] + [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] + [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] + [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] + [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] + [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] + [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] + public void SaveWebpPageNumber(int page, bool withAnnotations = false) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.webp"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + SaveWebp(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(false, DisplayName = "Without annotations")] + [DataRow(true, DisplayName = "With annotations")] + public void SaveWebpPages(bool withAnnotations = false) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int page = 0; + + foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.webp"); + + using var outputStream = CreateOutputStream(expectedPath); + image.Encode(outputStream, SKEncodedImageFormat.Webp, 100); + + CompareStreams(expectedPath, outputStream); + + page++; + } + } #if NET6_0_OR_GREATER [TestMethod] @@ -114,80 +114,80 @@ public async Task SaveWebpPagesAsync(bool withAnnotations = false) } #endif - [TestMethod] - [DataRow(0, DisplayName = "Page 1")] - [DataRow(1, DisplayName = "Page 2")] - [DataRow(2, DisplayName = "Page 3")] - [DataRow(3, DisplayName = "Page 4")] - [DataRow(4, DisplayName = "Page 5")] - [DataRow(5, DisplayName = "Page 6")] - [DataRow(6, DisplayName = "Page 7")] - [DataRow(7, DisplayName = "Page 8")] - [DataRow(8, DisplayName = "Page 9")] - [DataRow(9, DisplayName = "Page 10")] - [DataRow(10, DisplayName = "Page 11")] - [DataRow(11, DisplayName = "Page 12")] - [DataRow(12, DisplayName = "Page 13")] - [DataRow(13, DisplayName = "Page 14")] - [DataRow(14, DisplayName = "Page 15")] - [DataRow(15, DisplayName = "Page 16")] - [DataRow(16, DisplayName = "Page 17")] - [DataRow(17, DisplayName = "Page 18")] - [DataRow(18, DisplayName = "Page 19")] - [DataRow(19, DisplayName = "Page 20")] - [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] - [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] - [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] - [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] - [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] - [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] - [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] - [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] - [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] - [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] - [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] - [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] - [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] - [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] - [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] - [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] - [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] - [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] - [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] - [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] - public void SavePngPageNumber(int page, bool withAnnotations = false) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.png"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - SavePng(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(false, DisplayName = "Without annotations")] - [DataRow(true, DisplayName = "With annotations")] - public void SavePngPages(bool withAnnotations = false) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - - int page = 0; - - foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.png"); - - using var outputStream = CreateOutputStream(expectedPath); - image.Encode(outputStream, SKEncodedImageFormat.Png, 100); - - CompareStreams(expectedPath, outputStream); - - page++; - } - } + [TestMethod] + [DataRow(0, DisplayName = "Page 1")] + [DataRow(1, DisplayName = "Page 2")] + [DataRow(2, DisplayName = "Page 3")] + [DataRow(3, DisplayName = "Page 4")] + [DataRow(4, DisplayName = "Page 5")] + [DataRow(5, DisplayName = "Page 6")] + [DataRow(6, DisplayName = "Page 7")] + [DataRow(7, DisplayName = "Page 8")] + [DataRow(8, DisplayName = "Page 9")] + [DataRow(9, DisplayName = "Page 10")] + [DataRow(10, DisplayName = "Page 11")] + [DataRow(11, DisplayName = "Page 12")] + [DataRow(12, DisplayName = "Page 13")] + [DataRow(13, DisplayName = "Page 14")] + [DataRow(14, DisplayName = "Page 15")] + [DataRow(15, DisplayName = "Page 16")] + [DataRow(16, DisplayName = "Page 17")] + [DataRow(17, DisplayName = "Page 18")] + [DataRow(18, DisplayName = "Page 19")] + [DataRow(19, DisplayName = "Page 20")] + [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] + [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] + [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] + [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] + [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] + [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] + [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] + [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] + [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] + [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] + [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] + [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] + [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] + [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] + [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] + [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] + [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] + [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] + [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] + [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] + public void SavePngPageNumber(int page, bool withAnnotations = false) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + SavePng(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(false, DisplayName = "Without annotations")] + [DataRow(true, DisplayName = "With annotations")] + public void SavePngPages(bool withAnnotations = false) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int page = 0; + + foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.png"); + + using var outputStream = CreateOutputStream(expectedPath); + image.Encode(outputStream, SKEncodedImageFormat.Png, 100); + + CompareStreams(expectedPath, outputStream); + + page++; + } + } #if NET6_0_OR_GREATER [TestMethod] @@ -213,80 +213,80 @@ public async Task SavePngPagesAsync(bool withAnnotations = false) } #endif - [TestMethod] - [DataRow(0, DisplayName = "Page 1")] - [DataRow(1, DisplayName = "Page 2")] - [DataRow(2, DisplayName = "Page 3")] - [DataRow(3, DisplayName = "Page 4")] - [DataRow(4, DisplayName = "Page 5")] - [DataRow(5, DisplayName = "Page 6")] - [DataRow(6, DisplayName = "Page 7")] - [DataRow(7, DisplayName = "Page 8")] - [DataRow(8, DisplayName = "Page 9")] - [DataRow(9, DisplayName = "Page 10")] - [DataRow(10, DisplayName = "Page 11")] - [DataRow(11, DisplayName = "Page 12")] - [DataRow(12, DisplayName = "Page 13")] - [DataRow(13, DisplayName = "Page 14")] - [DataRow(14, DisplayName = "Page 15")] - [DataRow(15, DisplayName = "Page 16")] - [DataRow(16, DisplayName = "Page 17")] - [DataRow(17, DisplayName = "Page 18")] - [DataRow(18, DisplayName = "Page 19")] - [DataRow(19, DisplayName = "Page 20")] - [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] - [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] - [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] - [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] - [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] - [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] - [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] - [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] - [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] - [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] - [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] - [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] - [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] - [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] - [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] - [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] - [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] - [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] - [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] - [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] - public void SaveJpegPageNumber(int page, bool withAnnotations = false) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.jpg"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - SaveJpeg(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(false, DisplayName = "Without annotations")] - [DataRow(true, DisplayName = "With annotations")] - public void SaveJpegPages(bool withAnnotations = false) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); - - int page = 0; - - foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.jpg"); - - using var outputStream = CreateOutputStream(expectedPath); - image.Encode(outputStream, SKEncodedImageFormat.Jpeg, 100); - - CompareStreams(expectedPath, outputStream); - - page++; - } - } + [TestMethod] + [DataRow(0, DisplayName = "Page 1")] + [DataRow(1, DisplayName = "Page 2")] + [DataRow(2, DisplayName = "Page 3")] + [DataRow(3, DisplayName = "Page 4")] + [DataRow(4, DisplayName = "Page 5")] + [DataRow(5, DisplayName = "Page 6")] + [DataRow(6, DisplayName = "Page 7")] + [DataRow(7, DisplayName = "Page 8")] + [DataRow(8, DisplayName = "Page 9")] + [DataRow(9, DisplayName = "Page 10")] + [DataRow(10, DisplayName = "Page 11")] + [DataRow(11, DisplayName = "Page 12")] + [DataRow(12, DisplayName = "Page 13")] + [DataRow(13, DisplayName = "Page 14")] + [DataRow(14, DisplayName = "Page 15")] + [DataRow(15, DisplayName = "Page 16")] + [DataRow(16, DisplayName = "Page 17")] + [DataRow(17, DisplayName = "Page 18")] + [DataRow(18, DisplayName = "Page 19")] + [DataRow(19, DisplayName = "Page 20")] + [DataRow(0, true, DisplayName = "Page 1 (with annotations)")] + [DataRow(1, true, DisplayName = "Page 2 (with annotations)")] + [DataRow(2, true, DisplayName = "Page 3 (with annotations)")] + [DataRow(3, true, DisplayName = "Page 4 (with annotations)")] + [DataRow(4, true, DisplayName = "Page 5 (with annotations)")] + [DataRow(5, true, DisplayName = "Page 6 (with annotations)")] + [DataRow(6, true, DisplayName = "Page 7 (with annotations)")] + [DataRow(7, true, DisplayName = "Page 8 (with annotations)")] + [DataRow(8, true, DisplayName = "Page 9 (with annotations)")] + [DataRow(9, true, DisplayName = "Page 10 (with annotations)")] + [DataRow(10, true, DisplayName = "Page 11 (with annotations)")] + [DataRow(11, true, DisplayName = "Page 12 (with annotations)")] + [DataRow(12, true, DisplayName = "Page 13 (with annotations)")] + [DataRow(13, true, DisplayName = "Page 14 (with annotations)")] + [DataRow(14, true, DisplayName = "Page 15 (with annotations)")] + [DataRow(15, true, DisplayName = "Page 16 (with annotations)")] + [DataRow(16, true, DisplayName = "Page 17 (with annotations)")] + [DataRow(17, true, DisplayName = "Page 18 (with annotations)")] + [DataRow(18, true, DisplayName = "Page 19 (with annotations)")] + [DataRow(19, true, DisplayName = "Page 20 (with annotations)")] + public void SaveJpegPageNumber(int page, bool withAnnotations = false) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.jpg"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + SaveJpeg(outputStream, inputStream, page: page, options: new(Dpi: 40, WithAnnotations: withAnnotations)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(false, DisplayName = "Without annotations")] + [DataRow(true, DisplayName = "With annotations")] + public void SaveJpegPages(bool withAnnotations = false) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "Wikimedia_Commons_web.pdf")); + + int page = 0; + + foreach (var image in ToImages(inputStream, options: new(Dpi: 40, WithAnnotations: withAnnotations))) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"Wikimedia_Commons_web_{page}{(withAnnotations ? "_ANNOT" : string.Empty)}.jpg"); + + using var outputStream = CreateOutputStream(expectedPath); + image.Encode(outputStream, SKEncodedImageFormat.Jpeg, 100); + + CompareStreams(expectedPath, outputStream); + + page++; + } + } #if NET6_0_OR_GREATER [TestMethod] @@ -312,57 +312,57 @@ public async Task SaveJpegPagesAsync(bool withAnnotations = false) } #endif - [TestMethod] - [DataRow(10, DisplayName = "10 DPI")] - [DataRow(30, DisplayName = "30 DPI")] - [DataRow(100, DisplayName = "100 DPI")] - [DataRow(300, DisplayName = "300 DPI")] - [DataRow(600, DisplayName = "600 DPI")] - [DataRow(1200, DisplayName = "1200 DPI")] - [DataRow(10, true, DisplayName = "10 DPI (with annotations)")] - [DataRow(30, true, DisplayName = "30 DPI (with annotations)")] - [DataRow(100, true, DisplayName = "100 DPI (with annotations)")] - [DataRow(300, true, DisplayName = "300 DPI (with annotations)")] - [DataRow(600, true, DisplayName = "600 DPI (with annotations)")] - [DataRow(1200, true, DisplayName = "1200 DPI (with annotations)")] - public void SavePngDpi(int dpi, bool withAnnotations = false) - { - using var pdfStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - using var image = ToImage(pdfStream, options: new(Dpi: dpi, WithAnnotations: withAnnotations)); - - using var pdfStream2 = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - using var image2 = ToImage(pdfStream2, options: new(Dpi: 300, WithAnnotations: withAnnotations)); - - Assert.IsNotNull(image); - Assert.IsTrue(Math.Abs(image.Width - image2.Width * (dpi / 300.0)) < 3); - Assert.IsTrue(Math.Abs(image.Height - image2.Height * (dpi / 300.0)) < 3); - } - - [TestMethod] - [DataRow(10, DisplayName = "10 DPI")] - [DataRow(30, DisplayName = "30 DPI")] - [DataRow(100, DisplayName = "100 DPI")] - [DataRow(300, DisplayName = "300 DPI")] - [DataRow(600, DisplayName = "600 DPI")] - [DataRow(1200, DisplayName = "1200 DPI")] - [DataRow(10, true, DisplayName = "10 DPI (with annotations)")] - [DataRow(30, true, DisplayName = "30 DPI (with annotations)")] - [DataRow(100, true, DisplayName = "100 DPI (with annotations)")] - [DataRow(300, true, DisplayName = "300 DPI (with annotations)")] - [DataRow(600, true, DisplayName = "600 DPI (with annotations)")] - [DataRow(1200, true, DisplayName = "1200 DPI (with annotations)")] - public void SavePngDpiImages(int dpi, bool withAnnotations = false) - { - using var pdfStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - using var image = ToImages(pdfStream, options: new(Dpi: dpi, WithAnnotations: withAnnotations)).Single(); - - using var pdfStream2 = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - using var image2 = ToImages(pdfStream2, options: new(Dpi: 300, WithAnnotations: withAnnotations)).Single(); - - Assert.IsNotNull(image); - Assert.IsTrue(Math.Abs(image.Width - image2.Width * (dpi / 300.0)) < 3); - Assert.IsTrue(Math.Abs(image.Height - image2.Height * (dpi / 300.0)) < 3); - } + [TestMethod] + [DataRow(10, DisplayName = "10 DPI")] + [DataRow(30, DisplayName = "30 DPI")] + [DataRow(100, DisplayName = "100 DPI")] + [DataRow(300, DisplayName = "300 DPI")] + [DataRow(600, DisplayName = "600 DPI")] + [DataRow(1200, DisplayName = "1200 DPI")] + [DataRow(10, true, DisplayName = "10 DPI (with annotations)")] + [DataRow(30, true, DisplayName = "30 DPI (with annotations)")] + [DataRow(100, true, DisplayName = "100 DPI (with annotations)")] + [DataRow(300, true, DisplayName = "300 DPI (with annotations)")] + [DataRow(600, true, DisplayName = "600 DPI (with annotations)")] + [DataRow(1200, true, DisplayName = "1200 DPI (with annotations)")] + public void SavePngDpi(int dpi, bool withAnnotations = false) + { + using var pdfStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + using var image = ToImage(pdfStream, options: new(Dpi: dpi, WithAnnotations: withAnnotations)); + + using var pdfStream2 = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + using var image2 = ToImage(pdfStream2, options: new(Dpi: 300, WithAnnotations: withAnnotations)); + + Assert.IsNotNull(image); + Assert.IsTrue(Math.Abs(image.Width - image2.Width * (dpi / 300.0)) < 3); + Assert.IsTrue(Math.Abs(image.Height - image2.Height * (dpi / 300.0)) < 3); + } + + [TestMethod] + [DataRow(10, DisplayName = "10 DPI")] + [DataRow(30, DisplayName = "30 DPI")] + [DataRow(100, DisplayName = "100 DPI")] + [DataRow(300, DisplayName = "300 DPI")] + [DataRow(600, DisplayName = "600 DPI")] + [DataRow(1200, DisplayName = "1200 DPI")] + [DataRow(10, true, DisplayName = "10 DPI (with annotations)")] + [DataRow(30, true, DisplayName = "30 DPI (with annotations)")] + [DataRow(100, true, DisplayName = "100 DPI (with annotations)")] + [DataRow(300, true, DisplayName = "300 DPI (with annotations)")] + [DataRow(600, true, DisplayName = "600 DPI (with annotations)")] + [DataRow(1200, true, DisplayName = "1200 DPI (with annotations)")] + public void SavePngDpiImages(int dpi, bool withAnnotations = false) + { + using var pdfStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + using var image = ToImages(pdfStream, options: new(Dpi: dpi, WithAnnotations: withAnnotations)).Single(); + + using var pdfStream2 = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + using var image2 = ToImages(pdfStream2, options: new(Dpi: 300, WithAnnotations: withAnnotations)).Single(); + + Assert.IsNotNull(image); + Assert.IsTrue(Math.Abs(image.Width - image2.Width * (dpi / 300.0)) < 3); + Assert.IsTrue(Math.Abs(image.Height - image2.Height * (dpi / 300.0)) < 3); + } #if NET6_0_OR_GREATER [TestMethod] @@ -389,15 +389,15 @@ public async Task SavePngDpiImagesAsync(int dpi, bool withAnnotations = false) } #endif - [TestMethod] - [DataRow("SocialPreview.pdf", 1)] - [DataRow("hundesteuer-anmeldung.pdf", 3)] - [DataRow("Wikimedia_Commons_web.pdf", 20)] - public void GetPageCountTest(string pdfFileName, int expectedPageCount) - { - using var pdfStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); - Assert.AreEqual(expectedPageCount, GetPageCount(pdfStream), $"The expected and actual page count for the file {pdfFileName} are not equal."); - } + [TestMethod] + [DataRow("SocialPreview.pdf", 1)] + [DataRow("hundesteuer-anmeldung.pdf", 3)] + [DataRow("Wikimedia_Commons_web.pdf", 20)] + public void GetPageCountTest(string pdfFileName, int expectedPageCount) + { + using var pdfStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); + Assert.AreEqual(expectedPageCount, GetPageCount(pdfStream), $"The expected and actual page count for the file {pdfFileName} are not equal."); + } #if NET6_0_OR_GREATER [TestMethod] @@ -451,5 +451,5 @@ await Assert.ThrowsExceptionAsync(async () => }); } #endif - } + } } \ No newline at end of file diff --git a/src/Tests/Compatibility/AntiAliasingTests.cs b/src/Tests/Compatibility/AntiAliasingTests.cs index a0db4423..d5e0698e 100644 --- a/src/Tests/Compatibility/AntiAliasingTests.cs +++ b/src/Tests/Compatibility/AntiAliasingTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using PDFtoImage; using System; @@ -18,7 +17,6 @@ public void Initialize() #if NET6_0_OR_GREATER if (!OperatingSystem.IsWindows() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) Assert.Inconclusive("This test must run on Windows, Linux or macOS."); -#pragma warning disable CS0618 #endif } diff --git a/src/Tests/Compatibility/ApiTests.cs b/src/Tests/Compatibility/ApiTests.cs index 35bc9770..c9f0da72 100644 --- a/src/Tests/Compatibility/ApiTests.cs +++ b/src/Tests/Compatibility/ApiTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using PDFtoImage.Tests; using System; @@ -10,80 +9,80 @@ namespace Tests.Compatibility { - [TestClass] - public class ApiTests : TestBase - { - [TestMethod] - public void SaveWebpStringNullException() - { + [TestClass] + public class ApiTests : TestBase + { + [TestMethod] + public void SaveWebpStringNullException() + { Assert.ThrowsException(() => SaveWebp((string)null!, (string)null!)); } - [TestMethod] - public void SaveWebpStreamNullException() - { - Assert.ThrowsException(() => SaveWebp((Stream)null!, (string)null!)); - } - - [TestMethod] - public void SavePngStringNullException() - { - Assert.ThrowsException(() => SavePng((string)null!, (string)null!)); - } - - [TestMethod] - public void SavePngStreamNullException() - { - Assert.ThrowsException(() => SavePng((Stream)null!, (string)null!)); - } - - [TestMethod] - public void SaveJpegStringNullException() - { - Assert.ThrowsException(() => SaveJpeg((string)null!, (string)null!)); - } - - [TestMethod] - public void SaveJpegStreamNullException() - { - Assert.ThrowsException(() => SaveJpeg((Stream)null!, (string)null!)); - } - - [TestMethod] - public void ToImagePdfStringNullException() - { - Assert.ThrowsException(() => ToImage((string)null!)); - } - - [TestMethod] - public void ToImagePdfArrayNullException() - { - Assert.ThrowsException(() => ToImage((byte[])null!)); - } - - [TestMethod] - public void ToImagePdfStreamNullException() - { - Assert.ThrowsException(() => ToImage((Stream)null!)); - } - - [TestMethod] - public void ToImagesPdfStringNullException() - { - Assert.ThrowsException(() => ToImages((string)null!).ToList()); - } - - [TestMethod] - public void ToImagesPdfArrayNullException() - { - Assert.ThrowsException(() => ToImages((byte[])null!).ToList()); - } - - [TestMethod] - public void ToImagesPdfStreamNullException() - { - Assert.ThrowsException(() => ToImages((Stream)null!).ToList()); - } + [TestMethod] + public void SaveWebpStreamNullException() + { + Assert.ThrowsException(() => SaveWebp((Stream)null!, (string)null!)); + } + + [TestMethod] + public void SavePngStringNullException() + { + Assert.ThrowsException(() => SavePng((string)null!, (string)null!)); + } + + [TestMethod] + public void SavePngStreamNullException() + { + Assert.ThrowsException(() => SavePng((Stream)null!, (string)null!)); + } + + [TestMethod] + public void SaveJpegStringNullException() + { + Assert.ThrowsException(() => SaveJpeg((string)null!, (string)null!)); + } + + [TestMethod] + public void SaveJpegStreamNullException() + { + Assert.ThrowsException(() => SaveJpeg((Stream)null!, (string)null!)); + } + + [TestMethod] + public void ToImagePdfStringNullException() + { + Assert.ThrowsException(() => ToImage((string)null!)); + } + + [TestMethod] + public void ToImagePdfArrayNullException() + { + Assert.ThrowsException(() => ToImage((byte[])null!)); + } + + [TestMethod] + public void ToImagePdfStreamNullException() + { + Assert.ThrowsException(() => ToImage((Stream)null!)); + } + + [TestMethod] + public void ToImagesPdfStringNullException() + { + Assert.ThrowsException(() => ToImages((string)null!).ToList()); + } + + [TestMethod] + public void ToImagesPdfArrayNullException() + { + Assert.ThrowsException(() => ToImages((byte[])null!).ToList()); + } + + [TestMethod] + public void ToImagesPdfStreamNullException() + { + Assert.ThrowsException(() => ToImages((Stream)null!).ToList()); + } #if NET6_0_OR_GREATER [TestMethod] @@ -120,74 +119,74 @@ await Assert.ThrowsExceptionAsync(async () => } #endif - [TestMethod] - public void ToImageStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void ToImageStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void ToImageStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenDefault() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenFalse() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream, false); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - } - - [TestMethod] - public void ToImagesStreamLeaveOpenTrue() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); - - var result = ToImages(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); - - foreach (var _ in result) ; - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - } + [TestMethod] + public void ToImageStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void ToImageStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream, false); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void ToImageStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenDefault() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling the default overload."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenFalse() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream, false); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + } + + [TestMethod] + public void ToImagesStreamLeaveOpenTrue() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); + + var result = ToImages(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open as long as the iterator is not used yet."); + + foreach (var _ in result) ; + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + } #if NET6_0_OR_GREATER [TestMethod] @@ -230,31 +229,31 @@ public async Task ToImagesAsyncStreamLeaveOpenTrue() } #endif - [TestMethod] - public void StreamMultipleCallsLeaveOpen() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); - Assert.IsTrue(inputStream.CanRead); + [TestMethod] + public void StreamMultipleCallsLeaveOpen() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf")); + Assert.IsTrue(inputStream.CanRead); PDFtoImage.Conversion.GetPageCount(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); PDFtoImage.Conversion.GetPageSizes(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - var image1 = ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + var image1 = ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - var image2 = ToImage(inputStream, true); - Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); + var image2 = ToImage(inputStream, true); + Assert.IsTrue(inputStream.CanRead, "The stream should be open when calling leaveOpen with true."); - Assert.IsTrue(image1.ByteCount > 0, "The rendered image should have content."); - Assert.AreEqual(image1.ByteCount, image2.ByteCount, "Both images should be equal (in byte size)."); + Assert.IsTrue(image1.ByteCount > 0, "The rendered image should have content."); + Assert.AreEqual(image1.ByteCount, image2.ByteCount, "Both images should be equal (in byte size)."); PDFtoImage.Conversion.GetPageSizes(inputStream, false); - Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); + Assert.IsFalse(inputStream.CanRead, "The stream should be closed when calling leaveOpen with false."); - Assert.ThrowsException(() => PDFtoImage.Conversion.GetPageCount(inputStream, false), "The stream should be closed and throw an exception."); - } - } + Assert.ThrowsException(() => PDFtoImage.Conversion.GetPageCount(inputStream, false), "The stream should be closed and throw an exception."); + } + } } \ No newline at end of file diff --git a/src/Tests/Compatibility/AspectRatioTests.cs b/src/Tests/Compatibility/AspectRatioTests.cs index 48a97070..f9c70cb7 100644 --- a/src/Tests/Compatibility/AspectRatioTests.cs +++ b/src/Tests/Compatibility/AspectRatioTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using PDFtoImage.Tests; using System.IO; @@ -7,408 +6,408 @@ namespace Tests.Compatibility { - [TestClass] - public class AspectRatioTests : TestBase - { - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] + [TestClass] + public class AspectRatioTests : TestBase + { + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] - [DataRow("SocialPreview.pdf")] - [DataRow("SocialPreview.pdf", 100, null, null)] - [DataRow("SocialPreview.pdf", 1000, null, null)] - [DataRow("SocialPreview.pdf", 2000, null, null)] - [DataRow("SocialPreview.pdf", null, 100, null)] - [DataRow("SocialPreview.pdf", null, 1000, null)] - [DataRow("SocialPreview.pdf", null, 2000, null)] - [DataRow("SocialPreview.pdf", 100, 100, null)] - [DataRow("SocialPreview.pdf", 1000, 1000, null)] - [DataRow("SocialPreview.pdf", 2000, 2000, null)] - [DataRow("SocialPreview.pdf", null, null, 96)] - [DataRow("SocialPreview.pdf", null, null, 300)] - [DataRow("SocialPreview.pdf", null, null, 600)] - [DataRow("SocialPreview.pdf", 100, null, 96)] - [DataRow("SocialPreview.pdf", 100, null, 300)] - [DataRow("SocialPreview.pdf", 100, null, 1200)] - [DataRow("SocialPreview.pdf", 1000, null, 96)] - [DataRow("SocialPreview.pdf", 1000, null, 300)] - [DataRow("SocialPreview.pdf", 1000, null, 1200)] - [DataRow("SocialPreview.pdf", 2000, null, 96)] - [DataRow("SocialPreview.pdf", 2000, null, 300)] - [DataRow("SocialPreview.pdf", 2000, null, 1200)] - [DataRow("SocialPreview.pdf", null, 100, 96)] - [DataRow("SocialPreview.pdf", null, 100, 300)] - [DataRow("SocialPreview.pdf", null, 100, 1200)] - [DataRow("SocialPreview.pdf", null, 1000, 96)] - [DataRow("SocialPreview.pdf", null, 1000, 300)] - [DataRow("SocialPreview.pdf", null, 1000, 1200)] - [DataRow("SocialPreview.pdf", null, 2000, 96)] - [DataRow("SocialPreview.pdf", null, 2000, 300)] - [DataRow("SocialPreview.pdf", null, 2000, 1200)] - [DataRow("SocialPreview.pdf", 100, 100, 96)] - [DataRow("SocialPreview.pdf", 100, 100, 300)] - [DataRow("SocialPreview.pdf", 100, 100, 1200)] - [DataRow("SocialPreview.pdf", 1000, 1000, 96)] - [DataRow("SocialPreview.pdf", 1000, 1000, 300)] - [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] - [DataRow("SocialPreview.pdf", 2000, 2000, 96)] - [DataRow("SocialPreview.pdf", 2000, 2000, 300)] - [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] + [DataRow("SocialPreview.pdf")] + [DataRow("SocialPreview.pdf", 100, null, null)] + [DataRow("SocialPreview.pdf", 1000, null, null)] + [DataRow("SocialPreview.pdf", 2000, null, null)] + [DataRow("SocialPreview.pdf", null, 100, null)] + [DataRow("SocialPreview.pdf", null, 1000, null)] + [DataRow("SocialPreview.pdf", null, 2000, null)] + [DataRow("SocialPreview.pdf", 100, 100, null)] + [DataRow("SocialPreview.pdf", 1000, 1000, null)] + [DataRow("SocialPreview.pdf", 2000, 2000, null)] + [DataRow("SocialPreview.pdf", null, null, 96)] + [DataRow("SocialPreview.pdf", null, null, 300)] + [DataRow("SocialPreview.pdf", null, null, 600)] + [DataRow("SocialPreview.pdf", 100, null, 96)] + [DataRow("SocialPreview.pdf", 100, null, 300)] + [DataRow("SocialPreview.pdf", 100, null, 1200)] + [DataRow("SocialPreview.pdf", 1000, null, 96)] + [DataRow("SocialPreview.pdf", 1000, null, 300)] + [DataRow("SocialPreview.pdf", 1000, null, 1200)] + [DataRow("SocialPreview.pdf", 2000, null, 96)] + [DataRow("SocialPreview.pdf", 2000, null, 300)] + [DataRow("SocialPreview.pdf", 2000, null, 1200)] + [DataRow("SocialPreview.pdf", null, 100, 96)] + [DataRow("SocialPreview.pdf", null, 100, 300)] + [DataRow("SocialPreview.pdf", null, 100, 1200)] + [DataRow("SocialPreview.pdf", null, 1000, 96)] + [DataRow("SocialPreview.pdf", null, 1000, 300)] + [DataRow("SocialPreview.pdf", null, 1000, 1200)] + [DataRow("SocialPreview.pdf", null, 2000, 96)] + [DataRow("SocialPreview.pdf", null, 2000, 300)] + [DataRow("SocialPreview.pdf", null, 2000, 1200)] + [DataRow("SocialPreview.pdf", 100, 100, 96)] + [DataRow("SocialPreview.pdf", 100, 100, 300)] + [DataRow("SocialPreview.pdf", 100, 100, 1200)] + [DataRow("SocialPreview.pdf", 1000, 1000, 96)] + [DataRow("SocialPreview.pdf", 1000, 1000, 300)] + [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] + [DataRow("SocialPreview.pdf", 2000, 2000, 96)] + [DataRow("SocialPreview.pdf", 2000, 2000, 300)] + [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf")] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] - public void WithoutAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false)); + [DataRow("Wikimedia_Commons_web.pdf")] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] + public void WithoutAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream = CreateOutputStream(expectedPath); - if (dpi != null) - SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false, dpi: dpi.Value); - else - SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false); + if (dpi != null) + SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false, dpi: dpi.Value); + else + SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, null)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, null)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, null)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, null, 600)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, 1200)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 96)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 300)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, 1200)] - [DataRow("SocialPreview.pdf")] - [DataRow("SocialPreview.pdf", 100, null, null)] - [DataRow("SocialPreview.pdf", 1000, null, null)] - [DataRow("SocialPreview.pdf", 2000, null, null)] - [DataRow("SocialPreview.pdf", null, 100, null)] - [DataRow("SocialPreview.pdf", null, 1000, null)] - [DataRow("SocialPreview.pdf", null, 2000, null)] - [DataRow("SocialPreview.pdf", 100, 100, null)] - [DataRow("SocialPreview.pdf", 1000, 1000, null)] - [DataRow("SocialPreview.pdf", 2000, 2000, null)] - [DataRow("SocialPreview.pdf", null, null, 96)] - [DataRow("SocialPreview.pdf", null, null, 300)] - [DataRow("SocialPreview.pdf", null, null, 600)] - [DataRow("SocialPreview.pdf", 100, null, 96)] - [DataRow("SocialPreview.pdf", 100, null, 300)] - [DataRow("SocialPreview.pdf", 100, null, 1200)] - [DataRow("SocialPreview.pdf", 1000, null, 96)] - [DataRow("SocialPreview.pdf", 1000, null, 300)] - [DataRow("SocialPreview.pdf", 1000, null, 1200)] - [DataRow("SocialPreview.pdf", 2000, null, 96)] - [DataRow("SocialPreview.pdf", 2000, null, 300)] - [DataRow("SocialPreview.pdf", 2000, null, 1200)] - [DataRow("SocialPreview.pdf", null, 100, 96)] - [DataRow("SocialPreview.pdf", null, 100, 300)] - [DataRow("SocialPreview.pdf", null, 100, 1200)] - [DataRow("SocialPreview.pdf", null, 1000, 96)] - [DataRow("SocialPreview.pdf", null, 1000, 300)] - [DataRow("SocialPreview.pdf", null, 1000, 1200)] - [DataRow("SocialPreview.pdf", null, 2000, 96)] - [DataRow("SocialPreview.pdf", null, 2000, 300)] - [DataRow("SocialPreview.pdf", null, 2000, 1200)] - [DataRow("SocialPreview.pdf", 100, 100, 96)] - [DataRow("SocialPreview.pdf", 100, 100, 300)] - [DataRow("SocialPreview.pdf", 100, 100, 1200)] - [DataRow("SocialPreview.pdf", 1000, 1000, 96)] - [DataRow("SocialPreview.pdf", 1000, 1000, 300)] - [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] - [DataRow("SocialPreview.pdf", 2000, 2000, 96)] - [DataRow("SocialPreview.pdf", 2000, 2000, 300)] - [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] + [DataRow("SocialPreview.pdf")] + [DataRow("SocialPreview.pdf", 100, null, null)] + [DataRow("SocialPreview.pdf", 1000, null, null)] + [DataRow("SocialPreview.pdf", 2000, null, null)] + [DataRow("SocialPreview.pdf", null, 100, null)] + [DataRow("SocialPreview.pdf", null, 1000, null)] + [DataRow("SocialPreview.pdf", null, 2000, null)] + [DataRow("SocialPreview.pdf", 100, 100, null)] + [DataRow("SocialPreview.pdf", 1000, 1000, null)] + [DataRow("SocialPreview.pdf", 2000, 2000, null)] + [DataRow("SocialPreview.pdf", null, null, 96)] + [DataRow("SocialPreview.pdf", null, null, 300)] + [DataRow("SocialPreview.pdf", null, null, 600)] + [DataRow("SocialPreview.pdf", 100, null, 96)] + [DataRow("SocialPreview.pdf", 100, null, 300)] + [DataRow("SocialPreview.pdf", 100, null, 1200)] + [DataRow("SocialPreview.pdf", 1000, null, 96)] + [DataRow("SocialPreview.pdf", 1000, null, 300)] + [DataRow("SocialPreview.pdf", 1000, null, 1200)] + [DataRow("SocialPreview.pdf", 2000, null, 96)] + [DataRow("SocialPreview.pdf", 2000, null, 300)] + [DataRow("SocialPreview.pdf", 2000, null, 1200)] + [DataRow("SocialPreview.pdf", null, 100, 96)] + [DataRow("SocialPreview.pdf", null, 100, 300)] + [DataRow("SocialPreview.pdf", null, 100, 1200)] + [DataRow("SocialPreview.pdf", null, 1000, 96)] + [DataRow("SocialPreview.pdf", null, 1000, 300)] + [DataRow("SocialPreview.pdf", null, 1000, 1200)] + [DataRow("SocialPreview.pdf", null, 2000, 96)] + [DataRow("SocialPreview.pdf", null, 2000, 300)] + [DataRow("SocialPreview.pdf", null, 2000, 1200)] + [DataRow("SocialPreview.pdf", 100, 100, 96)] + [DataRow("SocialPreview.pdf", 100, 100, 300)] + [DataRow("SocialPreview.pdf", 100, 100, 1200)] + [DataRow("SocialPreview.pdf", 1000, 1000, 96)] + [DataRow("SocialPreview.pdf", 1000, 1000, 300)] + [DataRow("SocialPreview.pdf", 1000, 1000, 1200)] + [DataRow("SocialPreview.pdf", 2000, 2000, 96)] + [DataRow("SocialPreview.pdf", 2000, 2000, 300)] + [DataRow("SocialPreview.pdf", 2000, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf")] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] - public void WithAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true)); + [DataRow("Wikimedia_Commons_web.pdf")] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, null)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, null)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, null)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, null, 600)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, 1200)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 96)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 300)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)] + public void WithAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream = CreateOutputStream(expectedPath); - if (dpi != null) - SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true, dpi: dpi.Value); - else - SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true); + if (dpi != null) + SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true, dpi: dpi.Value); + else + SaveJpeg(outputStream, inputStream, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, false)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, false)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, false)] - [DataRow("hundesteuer-anmeldung.pdf", 100, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, null, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 100, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 1000, true)] - [DataRow("hundesteuer-anmeldung.pdf", null, 2000, true)] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100, true)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, true)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, true)] + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, false)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, false)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, false)] + [DataRow("hundesteuer-anmeldung.pdf", 100, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, null, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 100, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 1000, true)] + [DataRow("hundesteuer-anmeldung.pdf", null, 2000, true)] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100, true)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000, true)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000, true)] - [DataRow("SocialPreview.pdf", 100, null, false)] - [DataRow("SocialPreview.pdf", 1000, null, false)] - [DataRow("SocialPreview.pdf", 2000, null, false)] - [DataRow("SocialPreview.pdf", null, 100, false)] - [DataRow("SocialPreview.pdf", null, 1000, false)] - [DataRow("SocialPreview.pdf", null, 2000, false)] - [DataRow("SocialPreview.pdf", 100, 100, false)] - [DataRow("SocialPreview.pdf", 1000, 1000, false)] - [DataRow("SocialPreview.pdf", 2000, 2000, false)] - [DataRow("SocialPreview.pdf", 100, null, true)] - [DataRow("SocialPreview.pdf", 1000, null, true)] - [DataRow("SocialPreview.pdf", 2000, null, true)] - [DataRow("SocialPreview.pdf", null, 100, true)] - [DataRow("SocialPreview.pdf", null, 1000, true)] - [DataRow("SocialPreview.pdf", null, 2000, true)] - [DataRow("SocialPreview.pdf", 100, 100, true)] - [DataRow("SocialPreview.pdf", 1000, 1000, true)] - [DataRow("SocialPreview.pdf", 2000, 2000, true)] + [DataRow("SocialPreview.pdf", 100, null, false)] + [DataRow("SocialPreview.pdf", 1000, null, false)] + [DataRow("SocialPreview.pdf", 2000, null, false)] + [DataRow("SocialPreview.pdf", null, 100, false)] + [DataRow("SocialPreview.pdf", null, 1000, false)] + [DataRow("SocialPreview.pdf", null, 2000, false)] + [DataRow("SocialPreview.pdf", 100, 100, false)] + [DataRow("SocialPreview.pdf", 1000, 1000, false)] + [DataRow("SocialPreview.pdf", 2000, 2000, false)] + [DataRow("SocialPreview.pdf", 100, null, true)] + [DataRow("SocialPreview.pdf", 1000, null, true)] + [DataRow("SocialPreview.pdf", 2000, null, true)] + [DataRow("SocialPreview.pdf", null, 100, true)] + [DataRow("SocialPreview.pdf", null, 1000, true)] + [DataRow("SocialPreview.pdf", null, 2000, true)] + [DataRow("SocialPreview.pdf", 100, 100, true)] + [DataRow("SocialPreview.pdf", 1000, 1000, true)] + [DataRow("SocialPreview.pdf", 2000, 2000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, false)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, false)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, false)] - [DataRow("Wikimedia_Commons_web.pdf", 100, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, null, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 100, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 1000, true)] - [DataRow("Wikimedia_Commons_web.pdf", null, 2000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100, true)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, true)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, true)] - public void IgnoreDpi(string fileName, int? width = null, int? height = null, bool withAspectRatio = false) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio)); + [DataRow("Wikimedia_Commons_web.pdf", 100, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, false)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, false)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, false)] + [DataRow("Wikimedia_Commons_web.pdf", 100, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, null, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 100, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 1000, true)] + [DataRow("Wikimedia_Commons_web.pdf", null, 2000, true)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100, true)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000, true)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, true)] + public void IgnoreDpi(string fileName, int? width = null, int? height = null, bool withAspectRatio = false) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - for (int i = 72; i < 600; i += 100) - { - using var outputStream = CreateOutputStream(expectedPath); + for (int i = 72; i < 600; i += 100) + { + using var outputStream = CreateOutputStream(expectedPath); - ToImage(inputStream, true, dpi: i, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: withAspectRatio).Encode(outputStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream); - } - } + ToImage(inputStream, true, dpi: i, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: withAspectRatio).Encode(outputStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + CompareStreams(expectedPath, outputStream); + } + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 100, 100)] - [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000)] - [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000)] - [DataRow("SocialPreview.pdf", 100, 100)] - [DataRow("SocialPreview.pdf", 1000, 1000)] - [DataRow("SocialPreview.pdf", 2000, 2000)] - [DataRow("Wikimedia_Commons_web.pdf", 100, 100)] - [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000)] - [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000)] - public void IgnoreAspectRatio(string fileName, int width, int height) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 100, 100)] + [DataRow("hundesteuer-anmeldung.pdf", 1000, 1000)] + [DataRow("hundesteuer-anmeldung.pdf", 2000, 2000)] + [DataRow("SocialPreview.pdf", 100, 100)] + [DataRow("SocialPreview.pdf", 1000, 1000)] + [DataRow("SocialPreview.pdf", 2000, 2000)] + [DataRow("Wikimedia_Commons_web.pdf", 100, 100)] + [DataRow("Wikimedia_Commons_web.pdf", 1000, 1000)] + [DataRow("Wikimedia_Commons_web.pdf", 2000, 2000)] + public void IgnoreAspectRatio(string fileName, int width, int height) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream1 = CreateOutputStream(expectedPath); - using var outputStream2 = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream1 = CreateOutputStream(expectedPath); + using var outputStream2 = CreateOutputStream(expectedPath); - ToImage(inputStream, true, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - ToImage(inputStream, true, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: false).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, width: width, height: height, withAnnotations: true, withFormFill: true, withAspectRatio: true).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream1); - CompareStreams(expectedPath, outputStream2); - } + CompareStreams(expectedPath, outputStream1); + CompareStreams(expectedPath, outputStream2); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 96)] - [DataRow("hundesteuer-anmeldung.pdf", 300)] - [DataRow("hundesteuer-anmeldung.pdf", 600)] - [DataRow("SocialPreview.pdf", 96)] - [DataRow("SocialPreview.pdf", 300)] - [DataRow("SocialPreview.pdf", 600)] - [DataRow("Wikimedia_Commons_web.pdf", 96)] - [DataRow("Wikimedia_Commons_web.pdf", 300)] - [DataRow("Wikimedia_Commons_web.pdf", 600)] - public void IgnoreAspectRatioWithDpi(string fileName, int dpi) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 96)] + [DataRow("hundesteuer-anmeldung.pdf", 300)] + [DataRow("hundesteuer-anmeldung.pdf", 600)] + [DataRow("SocialPreview.pdf", 96)] + [DataRow("SocialPreview.pdf", 300)] + [DataRow("SocialPreview.pdf", 600)] + [DataRow("Wikimedia_Commons_web.pdf", 96)] + [DataRow("Wikimedia_Commons_web.pdf", 300)] + [DataRow("Wikimedia_Commons_web.pdf", 600)] + public void IgnoreAspectRatioWithDpi(string fileName, int dpi) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true)); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); - using var outputStream1 = CreateOutputStream(expectedPath); - using var outputStream2 = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName)); + using var outputStream1 = CreateOutputStream(expectedPath); + using var outputStream2 = CreateOutputStream(expectedPath); - ToImage(inputStream, true, dpi: dpi, withAnnotations: true, withFormFill: true, withAspectRatio: false).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - ToImage(inputStream, true, dpi: dpi, withAnnotations: true, withFormFill: true, withAspectRatio: true).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, dpi: dpi, withAnnotations: true, withFormFill: true, withAspectRatio: false).Encode(outputStream1, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); + ToImage(inputStream, true, dpi: dpi, withAnnotations: true, withFormFill: true, withAspectRatio: true).Encode(outputStream2, SkiaSharp.SKEncodedImageFormat.Jpeg, 100); - CompareStreams(expectedPath, outputStream1); - CompareStreams(expectedPath, outputStream2); - } + CompareStreams(expectedPath, outputStream1); + CompareStreams(expectedPath, outputStream2); + } - private static string GetExpectedFilename(string fileName, string? fileExtension, int? width, int? height, int? dpi, bool withAspectRatio) - => $"{fileName}_w={width?.ToString() ?? "null"}_h={height?.ToString() ?? "null"}_dpi={dpi?.ToString() ?? "null"}_aspectratio={withAspectRatio}{(fileExtension != null ? $".{fileExtension}" : string.Empty)}"; - } + private static string GetExpectedFilename(string fileName, string? fileExtension, int? width, int? height, int? dpi, bool withAspectRatio) + => $"{fileName}_w={width?.ToString() ?? "null"}_h={height?.ToString() ?? "null"}_dpi={dpi?.ToString() ?? "null"}_aspectratio={withAspectRatio}{(fileExtension != null ? $".{fileExtension}" : string.Empty)}"; + } } \ No newline at end of file diff --git a/src/Tests/Compatibility/BackgroundColorTests.cs b/src/Tests/Compatibility/BackgroundColorTests.cs index 290dda63..4ae4de9d 100644 --- a/src/Tests/Compatibility/BackgroundColorTests.cs +++ b/src/Tests/Compatibility/BackgroundColorTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using SkiaSharp; using System; diff --git a/src/Tests/Compatibility/ComparisonTests.cs b/src/Tests/Compatibility/ComparisonTests.cs index d280c54e..fe6190aa 100644 --- a/src/Tests/Compatibility/ComparisonTests.cs +++ b/src/Tests/Compatibility/ComparisonTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using PDFtoImage.Tests; using SkiaSharp; diff --git a/src/Tests/Compatibility/ExceptionTests.cs b/src/Tests/Compatibility/ExceptionTests.cs index e57a6eb2..cc08ef23 100644 --- a/src/Tests/Compatibility/ExceptionTests.cs +++ b/src/Tests/Compatibility/ExceptionTests.cs @@ -1,6 +1,4 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; -using PDFtoImage.Exceptions; using PDFtoImage.Tests; using System; using System.IO; @@ -9,17 +7,17 @@ namespace Tests.Compatibility { - [TestClass] - public class ExceptionTests : TestBase - { - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("SocialPreview.pdf")] - [DataRow("Wikimedia_Commons_web.pdf")] - public void ThrowsPageNotFound(string inputFile) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); - Assert.ThrowsException(() => ToImage(inputStream, page: 80085)); - } - } + [TestClass] + public class ExceptionTests : TestBase + { + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("SocialPreview.pdf")] + [DataRow("Wikimedia_Commons_web.pdf")] + public void ThrowsPageNotFound(string inputFile) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); + Assert.ThrowsException(() => ToImage(inputStream, page: 80085)); + } + } } \ No newline at end of file diff --git a/src/Tests/Compatibility/FormFillTests.cs b/src/Tests/Compatibility/FormFillTests.cs index 479351d9..1fd06112 100644 --- a/src/Tests/Compatibility/FormFillTests.cs +++ b/src/Tests/Compatibility/FormFillTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.IO; @@ -7,74 +6,73 @@ namespace Tests.Compatibility { - [TestClass] - public class FormFillTests - { - [TestInitialize] - public void Initialize() - { + [TestClass] + public class FormFillTests + { + [TestInitialize] + public void Initialize() + { #if NET6_0_OR_GREATER if (!OperatingSystem.IsWindows() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) Assert.Inconclusive("This test must run on Windows, Linux or macOS."); -#pragma warning disable CS0618 #endif } [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SaveWebpPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.webp"); + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SaveWebpPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.webp"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SaveWebp(outputStream, inputStream, dpi: 40); - else - SaveWebp(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); + if (withFormFill == null) + SaveWebp(outputStream, inputStream, dpi: 40); + else + SaveWebp(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SavePngPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.png"); + [TestMethod] + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SavePngPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.png"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SavePng(outputStream, inputStream, dpi: 40); - else - SavePng(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); + if (withFormFill == null) + SavePng(outputStream, inputStream, dpi: 40); + else + SavePng(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SaveJpegPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.jpg"); + [TestMethod] + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SaveJpegPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.jpg"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SaveJpeg(outputStream, inputStream, dpi: 40); - else - SaveJpeg(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); + if (withFormFill == null) + SaveJpeg(outputStream, inputStream, dpi: 40); + else + SaveJpeg(outputStream, inputStream, dpi: 40, withFormFill: withFormFill.Value); - CompareStreams(expectedPath, outputStream); - } - } + CompareStreams(expectedPath, outputStream); + } + } } \ No newline at end of file diff --git a/src/Tests/Compatibility/RotationTests.cs b/src/Tests/Compatibility/RotationTests.cs index 84ae4133..28c544fd 100644 --- a/src/Tests/Compatibility/RotationTests.cs +++ b/src/Tests/Compatibility/RotationTests.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS0618 using Microsoft.VisualStudio.TestTools.UnitTesting; using PDFtoImage; using PDFtoImage.Tests; @@ -9,126 +8,126 @@ namespace Tests.Compatibility { - [TestClass] - public class RotationTests : TestBase - { - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SaveWebpPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.webp"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SaveWebp(outputStream, inputStream, dpi: 40); - else - SaveWebp(outputStream, inputStream, dpi: 40, rotation: rotation.Value); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SavePngPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.png"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SavePng(outputStream, inputStream, dpi: 40); - else - SavePng(outputStream, inputStream, dpi: 40, rotation: rotation.Value); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SaveJpegPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.jpg"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SaveJpeg(outputStream, inputStream, dpi: 40); - else - SaveJpeg(outputStream, inputStream, dpi: 40, rotation: rotation.Value); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, null, null, false)] - [DataRow(PdfRotation.Rotate0, null, null, false)] - [DataRow(PdfRotation.Rotate90, null, null, false)] - [DataRow(PdfRotation.Rotate180, null, null, false)] - [DataRow(PdfRotation.Rotate270, null, null, false)] - [DataRow(null, null, null, true)] - [DataRow(PdfRotation.Rotate0, null, null, true)] - [DataRow(PdfRotation.Rotate90, null, null, true)] - [DataRow(PdfRotation.Rotate180, null, null, true)] - [DataRow(PdfRotation.Rotate270, null, null, true)] - [DataRow(null, 200, null, false)] - [DataRow(PdfRotation.Rotate0, 200, null, false)] - [DataRow(PdfRotation.Rotate90, 200, null, false)] - [DataRow(PdfRotation.Rotate180, 200, null, false)] - [DataRow(PdfRotation.Rotate270, 200, null, false)] - [DataRow(null, 200, null, true)] - [DataRow(PdfRotation.Rotate0, 200, null, true)] - [DataRow(PdfRotation.Rotate90, 200, null, true)] - [DataRow(PdfRotation.Rotate180, 200, null, true)] - [DataRow(PdfRotation.Rotate270, 200, null, true)] - [DataRow(null, null, 200, false)] - [DataRow(PdfRotation.Rotate0, null, 200, false)] - [DataRow(PdfRotation.Rotate90, null, 200, false)] - [DataRow(PdfRotation.Rotate180, null, 200, false)] - [DataRow(PdfRotation.Rotate270, 200, null, false)] - [DataRow(null, null, 200, true)] - [DataRow(PdfRotation.Rotate0, null, 200, true)] - [DataRow(PdfRotation.Rotate90, null, 200, true)] - [DataRow(PdfRotation.Rotate180, null, 200, true)] - [DataRow(PdfRotation.Rotate270, null, 200, true)] - [DataRow(null, 200, 200, false)] - [DataRow(PdfRotation.Rotate0, 200, 200, false)] - [DataRow(PdfRotation.Rotate90, 200, 200, false)] - [DataRow(PdfRotation.Rotate180, 200, 200, false)] - [DataRow(PdfRotation.Rotate270, 200, 200, false)] - [DataRow(null, 200, 200, true)] - [DataRow(PdfRotation.Rotate0, 200, 200, true)] - [DataRow(PdfRotation.Rotate90, 200, 200, true)] - [DataRow(PdfRotation.Rotate180, 200, 200, true)] - [DataRow(PdfRotation.Rotate270, 200, 200, true)] - public void WithWidthHeightAspect(PdfRotation? rotation, int? width, int? height, bool withAspectRatio) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}_{width?.ToString() ?? "null"}x{height?.ToString() ?? "null"}_{withAspectRatio}.png"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SavePng(outputStream, inputStream, dpi: 40, width: width, height: height, withAspectRatio: withAspectRatio); - else - SavePng(outputStream, inputStream, dpi: 40, width: width, height: height, withAspectRatio: withAspectRatio, rotation: rotation.Value); - - CompareStreams(expectedPath, outputStream); - } - } + [TestClass] + public class RotationTests : TestBase + { + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SaveWebpPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.webp"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SaveWebp(outputStream, inputStream, dpi: 40); + else + SaveWebp(outputStream, inputStream, dpi: 40, rotation: rotation.Value); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SavePngPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SavePng(outputStream, inputStream, dpi: 40); + else + SavePng(outputStream, inputStream, dpi: 40, rotation: rotation.Value); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SaveJpegPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.jpg"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SaveJpeg(outputStream, inputStream, dpi: 40); + else + SaveJpeg(outputStream, inputStream, dpi: 40, rotation: rotation.Value); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, null, null, false)] + [DataRow(PdfRotation.Rotate0, null, null, false)] + [DataRow(PdfRotation.Rotate90, null, null, false)] + [DataRow(PdfRotation.Rotate180, null, null, false)] + [DataRow(PdfRotation.Rotate270, null, null, false)] + [DataRow(null, null, null, true)] + [DataRow(PdfRotation.Rotate0, null, null, true)] + [DataRow(PdfRotation.Rotate90, null, null, true)] + [DataRow(PdfRotation.Rotate180, null, null, true)] + [DataRow(PdfRotation.Rotate270, null, null, true)] + [DataRow(null, 200, null, false)] + [DataRow(PdfRotation.Rotate0, 200, null, false)] + [DataRow(PdfRotation.Rotate90, 200, null, false)] + [DataRow(PdfRotation.Rotate180, 200, null, false)] + [DataRow(PdfRotation.Rotate270, 200, null, false)] + [DataRow(null, 200, null, true)] + [DataRow(PdfRotation.Rotate0, 200, null, true)] + [DataRow(PdfRotation.Rotate90, 200, null, true)] + [DataRow(PdfRotation.Rotate180, 200, null, true)] + [DataRow(PdfRotation.Rotate270, 200, null, true)] + [DataRow(null, null, 200, false)] + [DataRow(PdfRotation.Rotate0, null, 200, false)] + [DataRow(PdfRotation.Rotate90, null, 200, false)] + [DataRow(PdfRotation.Rotate180, null, 200, false)] + [DataRow(PdfRotation.Rotate270, 200, null, false)] + [DataRow(null, null, 200, true)] + [DataRow(PdfRotation.Rotate0, null, 200, true)] + [DataRow(PdfRotation.Rotate90, null, 200, true)] + [DataRow(PdfRotation.Rotate180, null, 200, true)] + [DataRow(PdfRotation.Rotate270, null, 200, true)] + [DataRow(null, 200, 200, false)] + [DataRow(PdfRotation.Rotate0, 200, 200, false)] + [DataRow(PdfRotation.Rotate90, 200, 200, false)] + [DataRow(PdfRotation.Rotate180, 200, 200, false)] + [DataRow(PdfRotation.Rotate270, 200, 200, false)] + [DataRow(null, 200, 200, true)] + [DataRow(PdfRotation.Rotate0, 200, 200, true)] + [DataRow(PdfRotation.Rotate90, 200, 200, true)] + [DataRow(PdfRotation.Rotate180, 200, 200, true)] + [DataRow(PdfRotation.Rotate270, 200, 200, true)] + public void WithWidthHeightAspect(PdfRotation? rotation, int? width, int? height, bool withAspectRatio) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}_{width?.ToString() ?? "null"}x{height?.ToString() ?? "null"}_{withAspectRatio}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SavePng(outputStream, inputStream, dpi: 40, width: width, height: height, withAspectRatio: withAspectRatio); + else + SavePng(outputStream, inputStream, dpi: 40, width: width, height: height, withAspectRatio: withAspectRatio, rotation: rotation.Value); + + CompareStreams(expectedPath, outputStream); + } + } } \ No newline at end of file diff --git a/src/Tests/ExceptionTests.cs b/src/Tests/ExceptionTests.cs index 87a5b4f8..89df444f 100644 --- a/src/Tests/ExceptionTests.cs +++ b/src/Tests/ExceptionTests.cs @@ -8,24 +8,24 @@ namespace Tests { - [TestClass] - public class ExceptionTests : TestBase - { - [TestMethod] - public void ThrowsInvalidFormat() - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "DummyImage.png")); - Assert.ThrowsException(() => GetPageCount(inputStream)); - } + [TestClass] + public class ExceptionTests : TestBase + { + [TestMethod] + public void ThrowsInvalidFormat() + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "DummyImage.png")); + Assert.ThrowsException(() => GetPageCount(inputStream)); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf")] - [DataRow("SocialPreview.pdf")] - [DataRow("Wikimedia_Commons_web.pdf")] - public void ThrowsPageNotFound(string inputFile) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); - Assert.ThrowsException(() => ToImage(inputStream, page: 80085)); - } - } + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf")] + [DataRow("SocialPreview.pdf")] + [DataRow("Wikimedia_Commons_web.pdf")] + public void ThrowsPageNotFound(string inputFile) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); + Assert.ThrowsException(() => ToImage(inputStream, page: 80085)); + } + } } \ No newline at end of file diff --git a/src/Tests/FormFillTests.cs b/src/Tests/FormFillTests.cs index 684869f5..19eca5c2 100644 --- a/src/Tests/FormFillTests.cs +++ b/src/Tests/FormFillTests.cs @@ -6,73 +6,73 @@ namespace Tests { - [TestClass] - public class FormFillTests - { - [TestInitialize] - public void Initialize() - { + [TestClass] + public class FormFillTests + { + [TestInitialize] + public void Initialize() + { #if NET6_0_OR_GREATER if (!OperatingSystem.IsWindows() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) Assert.Inconclusive("This test must run on Windows, Linux or macOS."); #endif - } + } - [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SaveWebpPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.webp"); + [TestMethod] + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SaveWebpPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.webp"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SaveWebp(outputStream, inputStream, options: new(Dpi: 40)); - else - SaveWebp(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); + if (withFormFill == null) + SaveWebp(outputStream, inputStream, options: new(Dpi: 40)); + else + SaveWebp(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SavePngPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.png"); + [TestMethod] + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SavePngPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.png"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SavePng(outputStream, inputStream, options: new(Dpi: 40)); - else - SavePng(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); + if (withFormFill == null) + SavePng(outputStream, inputStream, options: new(Dpi: 40)); + else + SavePng(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); - CompareStreams(expectedPath, outputStream); - } + CompareStreams(expectedPath, outputStream); + } - [TestMethod] - [DataRow(null, DisplayName = "Default (no form fill)")] - [DataRow(true, DisplayName = "Form fill")] - [DataRow(false, DisplayName = "No form fill")] - public void SaveJpegPageNumber(bool? withFormFill) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.jpg"); + [TestMethod] + [DataRow(null, DisplayName = "Default (no form fill)")] + [DataRow(true, DisplayName = "Form fill")] + [DataRow(false, DisplayName = "No form fill")] + public void SaveJpegPageNumber(bool? withFormFill) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), $"hundesteuer-anmeldung_{withFormFill ?? false}.jpg"); - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); - if (withFormFill == null) - SaveJpeg(outputStream, inputStream, options: new(Dpi: 40)); - else - SaveJpeg(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); + if (withFormFill == null) + SaveJpeg(outputStream, inputStream, options: new(Dpi: 40)); + else + SaveJpeg(outputStream, inputStream, options: new(Dpi: 40, WithFormFill: withFormFill.Value)); - CompareStreams(expectedPath, outputStream); - } - } + CompareStreams(expectedPath, outputStream); + } + } } \ No newline at end of file diff --git a/src/Tests/PasswordTests.cs b/src/Tests/PasswordTests.cs index 10212cb3..c4b26e78 100644 --- a/src/Tests/PasswordTests.cs +++ b/src/Tests/PasswordTests.cs @@ -7,33 +7,33 @@ namespace Tests { - [TestClass] - public class PasswordTests : TestBase - { - [TestMethod] - [DataRow("SocialPreview.pdf", null)] - [DataRow("SocialPreview.pdf", "")] - [DataRow("SocialPreview.pdf", "this doc needs no password")] - [DataRow("SocialPreview with password 123456 (RC4-40).pdf", "123456")] - [DataRow("SocialPreview with password 123456 (RC4-128).pdf", "123456")] - [DataRow("SocialPreview with password 123456 (AES-128).pdf", "123456")] - [DataRow("SocialPreview with password 123456 (AES-256).pdf", "123456")] - public void WithCorrectPassword(string inputFile, string? password = null) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); - var output = GetPageCount(inputStream, password: password); - Assert.AreEqual(1, output, "Page count should be 1, if the password was correct."); - } + [TestClass] + public class PasswordTests : TestBase + { + [TestMethod] + [DataRow("SocialPreview.pdf", null)] + [DataRow("SocialPreview.pdf", "")] + [DataRow("SocialPreview.pdf", "this doc needs no password")] + [DataRow("SocialPreview with password 123456 (RC4-40).pdf", "123456")] + [DataRow("SocialPreview with password 123456 (RC4-128).pdf", "123456")] + [DataRow("SocialPreview with password 123456 (AES-128).pdf", "123456")] + [DataRow("SocialPreview with password 123456 (AES-256).pdf", "123456")] + public void WithCorrectPassword(string inputFile, string? password = null) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); + var output = GetPageCount(inputStream, password: password); + Assert.AreEqual(1, output, "Page count should be 1, if the password was correct."); + } - [TestMethod] - [DataRow("SocialPreview with password 123456 (RC4-40).pdf", "In noreni per ipe")] - [DataRow("SocialPreview with password 123456 (RC4-128).pdf", "In noreni cora")] - [DataRow("SocialPreview with password 123456 (AES-128).pdf", "Tira mine per ito")] - [DataRow("SocialPreview with password 123456 (AES-256).pdf", "Ne domina")] - public void ThrowsIncorrectPassword(string inputFile, string? password = null) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); - Assert.ThrowsException(() => GetPageCount(inputStream, password: password)); - } - } + [TestMethod] + [DataRow("SocialPreview with password 123456 (RC4-40).pdf", "In noreni per ipe")] + [DataRow("SocialPreview with password 123456 (RC4-128).pdf", "In noreni cora")] + [DataRow("SocialPreview with password 123456 (AES-128).pdf", "Tira mine per ito")] + [DataRow("SocialPreview with password 123456 (AES-256).pdf", "Ne domina")] + public void ThrowsIncorrectPassword(string inputFile, string? password = null) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", inputFile)); + Assert.ThrowsException(() => GetPageCount(inputStream, password: password)); + } + } } \ No newline at end of file diff --git a/src/Tests/QueryTests.cs b/src/Tests/QueryTests.cs index 650f97fb..1939ed7f 100644 --- a/src/Tests/QueryTests.cs +++ b/src/Tests/QueryTests.cs @@ -5,71 +5,71 @@ namespace Tests { - [TestClass] - public class QueryTests : TestBase - { - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 3)] - [DataRow("SocialPreview.pdf", 1)] - [DataRow("Wikimedia_Commons_web.pdf", 20)] - public void GetPageCount(string pdfFileName, int expectedPageCount) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); + [TestClass] + public class QueryTests : TestBase + { + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 3)] + [DataRow("SocialPreview.pdf", 1)] + [DataRow("Wikimedia_Commons_web.pdf", 20)] + public void GetPageCount(string pdfFileName, int expectedPageCount) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); - Assert.AreEqual(expectedPageCount, PDFtoImage.Conversion.GetPageCount(inputStream), "Expected and actual PDF page count differs."); - } + Assert.AreEqual(expectedPageCount, PDFtoImage.Conversion.GetPageCount(inputStream), "Expected and actual PDF page count differs."); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 0, 595.56f, 842.04f)] - [DataRow("hundesteuer-anmeldung.pdf", 1, 595.56f, 842.04f)] - [DataRow("hundesteuer-anmeldung.pdf", 2, 595.56f, 842.04f)] - [DataRow("SocialPreview.pdf", 0, 1280f, 640f)] - [DataRow("Wikimedia_Commons_web.pdf", 0, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 1, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 2, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 3, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 4, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 5, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 6, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 7, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 8, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 9, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 10, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 11, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 12, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 13, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 14, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 15, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 16, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 17, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 18, 419.528f, 595.276f)] - [DataRow("Wikimedia_Commons_web.pdf", 19, 419.528f, 595.276f)] - public void GetPageSize(string pdfFileName, int page, float expectedPageWidth, float expectedPageHeight) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 0, 595.56f, 842.04f)] + [DataRow("hundesteuer-anmeldung.pdf", 1, 595.56f, 842.04f)] + [DataRow("hundesteuer-anmeldung.pdf", 2, 595.56f, 842.04f)] + [DataRow("SocialPreview.pdf", 0, 1280f, 640f)] + [DataRow("Wikimedia_Commons_web.pdf", 0, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 1, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 2, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 3, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 4, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 5, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 6, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 7, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 8, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 9, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 10, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 11, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 12, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 13, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 14, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 15, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 16, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 17, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 18, 419.528f, 595.276f)] + [DataRow("Wikimedia_Commons_web.pdf", 19, 419.528f, 595.276f)] + public void GetPageSize(string pdfFileName, int page, float expectedPageWidth, float expectedPageHeight) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); - var result = PDFtoImage.Conversion.GetPageSize(inputStream, page: page); + var result = PDFtoImage.Conversion.GetPageSize(inputStream, page: page); - Assert.AreEqual(expectedPageWidth, result.Width, 0.0001f, "Expected and actual PDF page width differs."); - Assert.AreEqual(expectedPageHeight, result.Height, 0.0001f, "Expected and actual PDF page height differs."); - } + Assert.AreEqual(expectedPageWidth, result.Width, 0.0001f, "Expected and actual PDF page width differs."); + Assert.AreEqual(expectedPageHeight, result.Height, 0.0001f, "Expected and actual PDF page height differs."); + } - [TestMethod] - [DataRow("hundesteuer-anmeldung.pdf", 3)] - [DataRow("SocialPreview.pdf", 1)] - [DataRow("Wikimedia_Commons_web.pdf", 20)] - public void GetPageSizes(string pdfFileName, int expectedSizeCount) - { - using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); + [TestMethod] + [DataRow("hundesteuer-anmeldung.pdf", 3)] + [DataRow("SocialPreview.pdf", 1)] + [DataRow("Wikimedia_Commons_web.pdf", 20)] + public void GetPageSizes(string pdfFileName, int expectedSizeCount) + { + using var inputStream = GetInputStream(Path.Combine("..", "Assets", pdfFileName)); - var result = PDFtoImage.Conversion.GetPageSizes(inputStream); + var result = PDFtoImage.Conversion.GetPageSizes(inputStream); - foreach (var size in result) - { - Assert.IsFalse(size.IsEmpty, "PDF page size cannot be empty."); - } + foreach (var size in result) + { + Assert.IsFalse(size.IsEmpty, "PDF page size cannot be empty."); + } - Assert.AreEqual(expectedSizeCount, result.Count, "Expected and actual PDF size count differs."); - } - } + Assert.AreEqual(expectedSizeCount, result.Count, "Expected and actual PDF size count differs."); + } + } } \ No newline at end of file diff --git a/src/Tests/RotationTests.cs b/src/Tests/RotationTests.cs index 4b6438fb..e11a2aad 100644 --- a/src/Tests/RotationTests.cs +++ b/src/Tests/RotationTests.cs @@ -8,126 +8,126 @@ namespace Tests { - [TestClass] - public class RotationTests : TestBase - { - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SaveWebpPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.webp"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SaveWebp(outputStream, inputStream, options: new(Dpi: 40)); - else - SaveWebp(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SavePngPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.png"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SavePng(outputStream, inputStream, options: new(Dpi: 40)); - else - SavePng(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, DisplayName = "Default (no rotation)")] - [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] - [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] - [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] - [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] - public void SaveJpegPageNumber(PdfRotation? rotation) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.jpg"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SaveJpeg(outputStream, inputStream, options: new(Dpi: 40)); - else - SaveJpeg(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); - - CompareStreams(expectedPath, outputStream); - } - - [TestMethod] - [DataRow(null, null, null, false)] - [DataRow(PdfRotation.Rotate0, null, null, false)] - [DataRow(PdfRotation.Rotate90, null, null, false)] - [DataRow(PdfRotation.Rotate180, null, null, false)] - [DataRow(PdfRotation.Rotate270, null, null, false)] - [DataRow(null, null, null, true)] - [DataRow(PdfRotation.Rotate0, null, null, true)] - [DataRow(PdfRotation.Rotate90, null, null, true)] - [DataRow(PdfRotation.Rotate180, null, null, true)] - [DataRow(PdfRotation.Rotate270, null, null, true)] - [DataRow(null, 200, null, false)] - [DataRow(PdfRotation.Rotate0, 200, null, false)] - [DataRow(PdfRotation.Rotate90, 200, null, false)] - [DataRow(PdfRotation.Rotate180, 200, null, false)] - [DataRow(PdfRotation.Rotate270, 200, null, false)] - [DataRow(null, 200, null, true)] - [DataRow(PdfRotation.Rotate0, 200, null, true)] - [DataRow(PdfRotation.Rotate90, 200, null, true)] - [DataRow(PdfRotation.Rotate180, 200, null, true)] - [DataRow(PdfRotation.Rotate270, 200, null, true)] - [DataRow(null, null, 200, false)] - [DataRow(PdfRotation.Rotate0, null, 200, false)] - [DataRow(PdfRotation.Rotate90, null, 200, false)] - [DataRow(PdfRotation.Rotate180, null, 200, false)] - [DataRow(PdfRotation.Rotate270, 200, null, false)] - [DataRow(null, null, 200, true)] - [DataRow(PdfRotation.Rotate0, null, 200, true)] - [DataRow(PdfRotation.Rotate90, null, 200, true)] - [DataRow(PdfRotation.Rotate180, null, 200, true)] - [DataRow(PdfRotation.Rotate270, null, 200, true)] - [DataRow(null, 200, 200, false)] - [DataRow(PdfRotation.Rotate0, 200, 200, false)] - [DataRow(PdfRotation.Rotate90, 200, 200, false)] - [DataRow(PdfRotation.Rotate180, 200, 200, false)] - [DataRow(PdfRotation.Rotate270, 200, 200, false)] - [DataRow(null, 200, 200, true)] - [DataRow(PdfRotation.Rotate0, 200, 200, true)] - [DataRow(PdfRotation.Rotate90, 200, 200, true)] - [DataRow(PdfRotation.Rotate180, 200, 200, true)] - [DataRow(PdfRotation.Rotate270, 200, 200, true)] - public void WithWidthHeightAspect(PdfRotation? rotation, int? width, int? height, bool withAspectRatio) - { - var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}_{width?.ToString() ?? "null"}x{height?.ToString() ?? "null"}_{withAspectRatio}.png"); - - using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); - using var outputStream = CreateOutputStream(expectedPath); - - if (rotation == null) - SavePng(outputStream, inputStream, options: new(Dpi: 40, Width: width, Height: height, WithAspectRatio: withAspectRatio)); - else - SavePng(outputStream, inputStream, options: new(Dpi: 40, Width: width, Height: height, WithAspectRatio: withAspectRatio, Rotation: rotation.Value)); - - CompareStreams(expectedPath, outputStream); - } - } + [TestClass] + public class RotationTests : TestBase + { + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SaveWebpPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.webp"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SaveWebp(outputStream, inputStream, options: new(Dpi: 40)); + else + SaveWebp(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SavePngPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SavePng(outputStream, inputStream, options: new(Dpi: 40)); + else + SavePng(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, DisplayName = "Default (no rotation)")] + [DataRow(PdfRotation.Rotate0, DisplayName = "No rotation")] + [DataRow(PdfRotation.Rotate90, DisplayName = "Rotated 90 degrees clockwise")] + [DataRow(PdfRotation.Rotate180, DisplayName = "Rotated 180 degrees")] + [DataRow(PdfRotation.Rotate270, DisplayName = "Rotated 90 degrees counter-clockwise")] + public void SaveJpegPageNumber(PdfRotation? rotation) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}.jpg"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SaveJpeg(outputStream, inputStream, options: new(Dpi: 40)); + else + SaveJpeg(outputStream, inputStream, options: new(Dpi: 40, Rotation: rotation.Value)); + + CompareStreams(expectedPath, outputStream); + } + + [TestMethod] + [DataRow(null, null, null, false)] + [DataRow(PdfRotation.Rotate0, null, null, false)] + [DataRow(PdfRotation.Rotate90, null, null, false)] + [DataRow(PdfRotation.Rotate180, null, null, false)] + [DataRow(PdfRotation.Rotate270, null, null, false)] + [DataRow(null, null, null, true)] + [DataRow(PdfRotation.Rotate0, null, null, true)] + [DataRow(PdfRotation.Rotate90, null, null, true)] + [DataRow(PdfRotation.Rotate180, null, null, true)] + [DataRow(PdfRotation.Rotate270, null, null, true)] + [DataRow(null, 200, null, false)] + [DataRow(PdfRotation.Rotate0, 200, null, false)] + [DataRow(PdfRotation.Rotate90, 200, null, false)] + [DataRow(PdfRotation.Rotate180, 200, null, false)] + [DataRow(PdfRotation.Rotate270, 200, null, false)] + [DataRow(null, 200, null, true)] + [DataRow(PdfRotation.Rotate0, 200, null, true)] + [DataRow(PdfRotation.Rotate90, 200, null, true)] + [DataRow(PdfRotation.Rotate180, 200, null, true)] + [DataRow(PdfRotation.Rotate270, 200, null, true)] + [DataRow(null, null, 200, false)] + [DataRow(PdfRotation.Rotate0, null, 200, false)] + [DataRow(PdfRotation.Rotate90, null, 200, false)] + [DataRow(PdfRotation.Rotate180, null, 200, false)] + [DataRow(PdfRotation.Rotate270, 200, null, false)] + [DataRow(null, null, 200, true)] + [DataRow(PdfRotation.Rotate0, null, 200, true)] + [DataRow(PdfRotation.Rotate90, null, 200, true)] + [DataRow(PdfRotation.Rotate180, null, 200, true)] + [DataRow(PdfRotation.Rotate270, null, 200, true)] + [DataRow(null, 200, 200, false)] + [DataRow(PdfRotation.Rotate0, 200, 200, false)] + [DataRow(PdfRotation.Rotate90, 200, 200, false)] + [DataRow(PdfRotation.Rotate180, 200, 200, false)] + [DataRow(PdfRotation.Rotate270, 200, 200, false)] + [DataRow(null, 200, 200, true)] + [DataRow(PdfRotation.Rotate0, 200, 200, true)] + [DataRow(PdfRotation.Rotate90, 200, 200, true)] + [DataRow(PdfRotation.Rotate180, 200, 200, true)] + [DataRow(PdfRotation.Rotate270, 200, 200, true)] + public void WithWidthHeightAspect(PdfRotation? rotation, int? width, int? height, bool withAspectRatio) + { + var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "Rotation", $"hundesteuer-anmeldung_{Enum.GetName(typeof(PdfRotation), rotation ?? PdfRotation.Rotate0)}_{width?.ToString() ?? "null"}x{height?.ToString() ?? "null"}_{withAspectRatio}.png"); + + using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf")); + using var outputStream = CreateOutputStream(expectedPath); + + if (rotation == null) + SavePng(outputStream, inputStream, options: new(Dpi: 40, Width: width, Height: height, WithAspectRatio: withAspectRatio)); + else + SavePng(outputStream, inputStream, options: new(Dpi: 40, Width: width, Height: height, WithAspectRatio: withAspectRatio, Rotation: rotation.Value)); + + CompareStreams(expectedPath, outputStream); + } + } } \ No newline at end of file diff --git a/src/Tests/TestBase.cs b/src/Tests/TestBase.cs index 645f888d..54e5e1cd 100644 --- a/src/Tests/TestBase.cs +++ b/src/Tests/TestBase.cs @@ -3,21 +3,21 @@ namespace PDFtoImage.Tests { - public abstract class TestBase - { - public TestContext? TestContext { get; set; } + public abstract class TestBase + { + public TestContext? TestContext { get; set; } - public static bool SaveOutputInGeneratedFolder { get; private set; } + public static bool SaveOutputInGeneratedFolder { get; private set; } - [TestInitialize] - public void Initialize() - { + [TestInitialize] + public void Initialize() + { #if NET6_0_OR_GREATER if (!OperatingSystem.IsWindows() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) Assert.Inconclusive("This test must run on Windows, Linux or macOS."); #endif - SaveOutputInGeneratedFolder = bool.Parse(TestContext?.Properties["SaveOutputInGeneratedFolder"]?.ToString() ?? false.ToString()); - } - } + SaveOutputInGeneratedFolder = bool.Parse(TestContext?.Properties["SaveOutputInGeneratedFolder"]?.ToString() ?? false.ToString()); + } + } } \ No newline at end of file diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index d84ab9a0..abb057a1 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -13,7 +13,7 @@ enable strict nullable - CA1416 + CS0618,CA1416 @@ -32,7 +32,7 @@ - - + + \ No newline at end of file diff --git a/src/WebConverter/Models/DummyFile.cs b/src/WebConverter/Models/DummyFile.cs index 3daf0944..5ab976fe 100644 --- a/src/WebConverter/Models/DummyFile.cs +++ b/src/WebConverter/Models/DummyFile.cs @@ -5,8 +5,8 @@ namespace PDFtoImage.WebConverter.Models { - public record DummyFile(string Name, DateTimeOffset LastModified, long Size, string ContentType) : IBrowserFile - { - public Stream OpenReadStream(long maxAllowedSize = 512000, CancellationToken cancellationToken = default) => throw new NotImplementedException(); - } + public record DummyFile(string Name, DateTimeOffset LastModified, long Size, string ContentType) : IBrowserFile + { + public Stream OpenReadStream(long maxAllowedSize = 512000, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + } } diff --git a/src/WebConverter/Models/FileStringyfied.cs b/src/WebConverter/Models/FileStringyfied.cs index c8b0d255..776fd04d 100644 --- a/src/WebConverter/Models/FileStringyfied.cs +++ b/src/WebConverter/Models/FileStringyfied.cs @@ -3,29 +3,29 @@ namespace PDFtoImage.WebConverter.Models { - public partial record FileStringyfied( - [property: JsonPropertyName("name")] - [property: JsonRequired] - string Name, + public partial record FileStringyfied( + [property: JsonPropertyName("name")] + [property: JsonRequired] + string Name, - [property: JsonPropertyName("lastModified")] - [property: JsonRequired] - [property: JsonConverter(typeof(UnixDateTimeConverter))] - DateTimeOffset LastModified, + [property: JsonPropertyName("lastModified")] + [property: JsonRequired] + [property: JsonConverter(typeof(UnixDateTimeConverter))] + DateTimeOffset LastModified, - [property: JsonPropertyName("size")] - [property: JsonRequired] - int Size, + [property: JsonPropertyName("size")] + [property: JsonRequired] + int Size, - [property: JsonPropertyName("type")] - [property: JsonRequired] - string Type, + [property: JsonPropertyName("type")] + [property: JsonRequired] + string Type, - [property: JsonPropertyName("data")] - [property: JsonRequired] - string Data - ) - { - public string GetData() => Data[(Data.IndexOf("base64,") + "base64,".Length)..]; - }; + [property: JsonPropertyName("data")] + [property: JsonRequired] + string Data + ) + { + public string GetData() => Data[(Data.IndexOf("base64,") + "base64,".Length)..]; + }; } \ No newline at end of file diff --git a/src/WebConverter/Models/FilesStringyfied.cs b/src/WebConverter/Models/FilesStringyfied.cs index 1e21bb2a..a4211cb1 100644 --- a/src/WebConverter/Models/FilesStringyfied.cs +++ b/src/WebConverter/Models/FilesStringyfied.cs @@ -2,17 +2,17 @@ namespace PDFtoImage.WebConverter.Models { - public record FilesStringyfied( - [property: JsonPropertyName("title")] - string? Title, + public record FilesStringyfied( + [property: JsonPropertyName("title")] + string? Title, - [property: JsonPropertyName("text")] - string? Text, + [property: JsonPropertyName("text")] + string? Text, - [property: JsonPropertyName("url")] - string? Url, + [property: JsonPropertyName("url")] + string? Url, - [property: JsonPropertyName("files")] - FileStringyfied[]? Files - ); + [property: JsonPropertyName("files")] + FileStringyfied[]? Files + ); } \ No newline at end of file diff --git a/src/WebConverter/Models/UnixDateTimeConverter.cs b/src/WebConverter/Models/UnixDateTimeConverter.cs index 54dbb040..89685846 100644 --- a/src/WebConverter/Models/UnixDateTimeConverter.cs +++ b/src/WebConverter/Models/UnixDateTimeConverter.cs @@ -4,16 +4,16 @@ namespace PDFtoImage.WebConverter.Models { - public class UnixDateTimeConverter : JsonConverter - { - public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64()); - } + public class UnixDateTimeConverter : JsonConverter + { + public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64()); + } - public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) - { - writer.WriteNumberValue(value.ToUnixTimeMilliseconds()); - } - } + public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options) + { + writer.WriteNumberValue(value.ToUnixTimeMilliseconds()); + } + } } \ No newline at end of file diff --git a/src/WebConverter/Pages/Index.razor.cs b/src/WebConverter/Pages/Index.razor.cs index 594f0e2b..8ea649e7 100644 --- a/src/WebConverter/Pages/Index.razor.cs +++ b/src/WebConverter/Pages/Index.razor.cs @@ -64,7 +64,7 @@ await args.File.GetTypeAsync() ); } - private void SetFile(IBrowserFile file, Stream stream) + private void SetFile(DummyFile file, Stream stream) { if (file == null) return; @@ -157,16 +157,16 @@ await Task.Factory.StartNew(() => { if (!Model.UseBounds) { - var pageSize = PDFtoImage.Conversion.GetPageSize(Model.Input, true, Model.Page, !string.IsNullOrEmpty(Model.Password) ? Model.Password : null); + var pageSize = PDFtoImage.Conversion.GetPageSize(Model.Input, Model.Page, true, !string.IsNullOrEmpty(Model.Password) ? Model.Password : null); Model.BoundsWidth = pageSize.Width; Model.BoundsHeight = pageSize.Height; } bitmap = PDFtoImage.Conversion.ToImage( Model.Input, + Model.Page, leaveOpen: true, password: !string.IsNullOrEmpty(Model.Password) ? Model.Password : null, - page: Model.Page, new RenderOptions( Dpi: Model.Dpi, Width: Model.Width, diff --git a/src/WebConverter/WebConverter.csproj b/src/WebConverter/WebConverter.csproj index 0d017a30..c039149d 100644 --- a/src/WebConverter/WebConverter.csproj +++ b/src/WebConverter/WebConverter.csproj @@ -7,7 +7,7 @@ PDFtoImage.WebConverter PDFtoImage.WebConverter PDFtoImage.WebConverter.Program - 4.0.2 + 4.1.0 true true @@ -40,8 +40,8 @@ - - + +