-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UglyToad.PdfPig.Rendering.Skia.Graphics and tests
- Loading branch information
Showing
20 changed files
with
2,814 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace UglyToad.PdfPig.Rendering.Skia.Tests | ||
{ | ||
internal static class Helpers | ||
{ | ||
private static readonly string _basePath = Path.GetFullPath("..\\..\\..\\..\\UglyToad.PdfPig.Tests\\Integration\\Documents"); | ||
|
||
public static string GetDocumentPath(string fileName) | ||
{ | ||
if (!fileName.EndsWith(".pdf")) | ||
{ | ||
fileName += ".pdf"; | ||
} | ||
|
||
return Path.Combine(_basePath, fileName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using SkiaSharp; | ||
using UglyToad.PdfPig.Rendering.Skia.Parser; | ||
|
||
namespace UglyToad.PdfPig.Rendering.Skia.Tests | ||
{ | ||
public class RenderTests | ||
{ | ||
[Fact] | ||
public void PigProductionHandbook() | ||
{ | ||
RenderDocument("Pig Production Handbook"); | ||
} | ||
|
||
[Fact] | ||
public void d_68_1990_01_A() | ||
{ | ||
RenderDocument("68-1990-01_A"); | ||
} | ||
|
||
[Fact] | ||
public void d_22060_A1_01_Plans_1() | ||
{ | ||
RenderDocument("22060_A1_01_Plans-1"); | ||
} | ||
|
||
private static void RenderDocument(string path) | ||
{ | ||
using (var document = PdfDocument.Open(Helpers.GetDocumentPath(path))) | ||
{ | ||
document.AddPageFactory<SKPicture>(typeof(SkiaPageFactory)); | ||
|
||
for (int p = 1; p <= document.NumberOfPages; p++) | ||
{ | ||
var page = document.GetPage(p); | ||
|
||
using (var picture = document.GetPage<SKPicture>(p)) | ||
{ | ||
Assert.NotNull(picture); | ||
|
||
using (var fs = new FileStream($"{path}_{p}.png", FileMode.Create)) | ||
using (var image = SKImage.FromPicture(picture, new SKSizeI((int)page.Width, (int)page.Height))) | ||
using (SKData d = image.Encode(SKEncodedImageFormat.Png, 100)) | ||
{ | ||
d.SaveTo(fs); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/UglyToad.PdfPig.Rendering.Skia.Tests/UglyToad.PdfPig.Rendering.Skia.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\UglyToad.PdfPig.Rendering.Skia\UglyToad.PdfPig.Rendering.Skia.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
Oops, something went wrong.