Skip to content

Commit

Permalink
Add optional parameter Bounds for clipping and margins (#71)
Browse files Browse the repository at this point in the history
* Introduction of RenderOptions

* Implement Bounds and update unit tests

* Update WebConverter and Readme
  • Loading branch information
sungaila authored Feb 27, 2024
1 parent 38a9306 commit c153124
Show file tree
Hide file tree
Showing 1,057 changed files with 4,943 additions and 1,484 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,18 @@ jobs:
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg
if-no-files-found: error
- name: Compress tests
shell: pwsh
run: Compress-Archive -Path src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/* -DestinationPath TestAssemblies.zip -CompressionLevel "Fastest"
- name: Publish tests
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
with:
name: Test assemblies
path: src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
path: TestAssemblies.zip
if-no-files-found: error
retention-days: 1
#compression-level: 0
compression-level: 0
- name: Publish test project MonoConsole
uses: actions/upload-artifact@v4
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
Expand Down Expand Up @@ -181,9 +184,13 @@ jobs:
run: mono MonoConsole/net481/PDFtoImage.FrameworkTests.MonoConsole.exe
- name: Download test assemblies
if: success() || failure()
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Test assemblies
- name: Expand tests
if: success() || failure()
shell: pwsh
run: Expand-Archive -Path TestAssemblies.zip -DestinationPath .
- name: .NET Framework 4.6.2
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net462/SaveOutputInGeneratedFolder.runsettings' || '' }}
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ Call a static method from `PDFtoImage.Conversion`:
https://github.com/sungaila/PDFtoImage.git?path=etc/UnityPackage
```

## Breaking changes in v4.0.0
Starting with v4.0.0 the struct `RenderOptions` is used for most methods. This is a breaking change when updating from v3.1.0 and older.
### Option 1: Migrate to new API
```csharp
// this will not compile anymore
PDFtoImage.Conversion.SaveJpeg("image.jpg", pdfStream, dpi: 300, rotation: PdfRotation.Rotate90);

// use this instead
PDFtoImage.Conversion.SaveJpeg("image.jpg", pdfStream, options: new(Dpi: 300, Rotation: PdfRotation.Rotate90));
```
### Option 2: Change namespace
Note: This namespace is used for backward compatibility and will be removed in a future version.
```csharp
using PDFtoImage;
using Conversion = PDFtoImage.Compatibility.Conversion;
```

## Supported runtimes
* [.NET (Core)](https://learn.microsoft.com/en-us/dotnet/core/introduction)
* [.NET Framework](https://learn.microsoft.com/en-us/dotnet/framework/get-started/overview)
Expand Down
2 changes: 1 addition & 1 deletion 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>3.1.0</Version>
<Version>4.0.0</Version>
<Configurations>Debug;Release;ReleaseSigned</Configurations>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static int Main(string[] args)
switch (Path.GetExtension(outputPath).ToLower())
{
case ".png":
Conversion.SavePng(outputPath, inputStream, page: page - 1, dpi: dpi, withAnnotations: withAnnotations, withFormFill: withFormFill);
Conversion.SavePng(outputPath, inputStream, page: page - 1, options: new(Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill));
break;
case ".jpg":
case ".jpeg":
Conversion.SaveJpeg(outputPath, inputStream, page: page - 1, dpi: dpi, withAnnotations: withAnnotations, withFormFill: withFormFill);
Conversion.SaveJpeg(outputPath, inputStream, page: page - 1, options: new(Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill));
break;
case ".webp":
Conversion.SaveWebp(outputPath, inputStream, page: page - 1, dpi: dpi, withAnnotations: withAnnotations, withFormFill: withFormFill);
Conversion.SaveWebp(outputPath, inputStream, page: page - 1, options: new(Dpi: dpi, WithAnnotations: withAnnotations, WithFormFill: withFormFill));
break;
default:
throw new InvalidOperationException("Only the following file extensions are supported: png, jpg/jpeg and webp.");
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 @@ -3,7 +3,7 @@
public class Program
{
private const int ExpectedWidth = 5333;
private const int ExpectedHeight = 2666;
private const int ExpectedHeight = 2667;

public static void Main()
{
Expand Down
4 changes: 2 additions & 2 deletions src/FrameworkTests/MonoAndroid/MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
<Folder Include="Resources\drawable\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.6" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.2" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.7" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.8.1" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FrameworkTests/MonoConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace PDFtoImage.FrameworkTests.MonoConsole
public class Program
{
private const int ExpectedWidth = 5333;
private const int ExpectedHeight = 2666;
private const int ExpectedHeight = 2667;

public static void Main()
{
Expand Down
Loading

0 comments on commit c153124

Please sign in to comment.