Skip to content

Commit

Permalink
Add methods for page indices, ranges and selection (#92)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sungaila authored Jul 24, 2024
1 parent 4ef60c0 commit e946ca0
Show file tree
Hide file tree
Showing 59 changed files with 4,135 additions and 3,175 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: PDFtoImage version
description: Which version of PDFtoImage is affected?
value: 4.0.2
value: 4.1.0
validations:
required: true
- type: dropdown
Expand Down
96 changes: 25 additions & 71 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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' || '' }}
Expand Down Expand Up @@ -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:
Expand All @@ -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 }}"
8 changes: 4 additions & 4 deletions .github/workflows/githubpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,4 +94,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main
uses: actions/deploy-pages@main
14 changes: 7 additions & 7 deletions .github/workflows/githubpages_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>PDFtoImage.Console</AssemblyName>
<RootNamespace>PDFtoImage.Console</RootNamespace>
<StartupObject>PDFtoImage.Console.Program</StartupObject>
<Version>4.0.2</Version>
<Version>4.1.0</Version>
<Configurations>Debug;Release;ReleaseSigned</Configurations>
</PropertyGroup>

Expand All @@ -17,7 +17,7 @@
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable</WarningsAsErrors>
<NoWarn>CA1416</NoWarn>
<NoWarn>CS0618,CA1416</NoWarn>
</PropertyGroup>

<!-- References -->
Expand Down
2 changes: 1 addition & 1 deletion src/FrameworkTests/AotConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand Down
1 change: 0 additions & 1 deletion src/FrameworkTests/AspNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
Expand Down
2 changes: 1 addition & 1 deletion src/FrameworkTests/AspNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
2 changes: 1 addition & 1 deletion src/FrameworkTests/MauiApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
Expand Down
4 changes: 2 additions & 2 deletions src/FrameworkTests/MauiApp/MauiApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.61" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.61" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.70" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.70" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace PDFtoImage.FrameworkTests.MauiApp
{
Expand Down
4 changes: 1 addition & 3 deletions src/FrameworkTests/MauiApp/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/FrameworkTests/Uwp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
Expand Down
1 change: 0 additions & 1 deletion src/PDFtoImage.Build.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit e946ca0

Please sign in to comment.