Skip to content

Commit 12bb4f4

Browse files
committed
Update PdfPig to 0.1.10-alpha, add support for DCT and JBIG2 filters and update tests
1 parent 8767a7e commit 12bb4f4

17 files changed

+192
-7
lines changed
165 Bytes
Loading
210 Bytes
Loading
-18.3 KB
Loading
-107 KB
Loading
-6.93 KB
Loading
-5.14 KB
Loading
-6.27 KB
Loading
-2.27 KB
Loading
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright 2024 BobLd
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License").
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System.IO;
16+
using UglyToad.PdfPig.Graphics.Colors;
17+
using Xunit;
18+
19+
namespace UglyToad.PdfPig.Rendering.Skia.Tests
20+
{
21+
public class GitHubIssues
22+
{
23+
private const int _scale = 2;
24+
private const string _outputPath = "OutputSpecific";
25+
26+
public GitHubIssues()
27+
{
28+
Directory.CreateDirectory(_outputPath);
29+
}
30+
31+
32+
[Fact]
33+
public void Issue27_1()
34+
{
35+
using (var document = PdfDocument.Open(Path.Combine("SpecificTestDocuments", "Go.pdf"), SkiaRenderingParsingOptions.Instance))
36+
{
37+
document.AddSkiaPageFactory();
38+
39+
for (int p = 1; p <= document.NumberOfPages; ++p)
40+
{
41+
using (var fs = new FileStream(Path.Combine(_outputPath, $"Go_{p}.png"), FileMode.Create))
42+
using (var ms = document.GetPageAsPng(p, _scale, RGBColor.White))
43+
{
44+
ms.WriteTo(fs);
45+
}
46+
}
47+
}
48+
}
49+
50+
[Fact]
51+
public void Issue27_2()
52+
{
53+
using (var document = PdfDocument.Open(Path.Combine("SpecificTestDocuments", "new.pdf"), SkiaRenderingParsingOptions.Instance))
54+
{
55+
document.AddSkiaPageFactory();
56+
57+
for (int p = 1; p <= document.NumberOfPages; ++p)
58+
{
59+
using (var fs = new FileStream(Path.Combine(_outputPath, $"new_{p}.png"), FileMode.Create))
60+
using (var ms = document.GetPageAsPng(p, _scale, RGBColor.White))
61+
{
62+
ms.WriteTo(fs);
63+
}
64+
}
65+
}
66+
}
67+
}
68+
}

UglyToad.PdfPig.Rendering.Skia.Tests/PdfToImageHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static bool TestResizeSinglePage(string pdfFile, int pageNumber, string e
120120
throw new NullReferenceException("Could not load expected image.");
121121
}
122122

123-
using (var document = PdfDocument.Open(docPath))
123+
using (var document = PdfDocument.Open(docPath, SkiaRenderingParsingOptions.Instance))
124124
{
125125
document.AddSkiaPageFactory();
126126
using (var actual = document.GetPageAsSKBitmap(pageNumber, scale, RGBColor.White))
@@ -188,7 +188,7 @@ public static bool TestSinglePage(string pdfFile, int pageNumber, string expecte
188188
throw new NullReferenceException("Could not load expected image.");
189189
}
190190

191-
using (var document = PdfDocument.Open(docPath))
191+
using (var document = PdfDocument.Open(docPath, SkiaRenderingParsingOptions.Instance))
192192
{
193193
document.AddSkiaPageFactory();
194194
using (var actual = document.GetPageAsSKBitmap(pageNumber, scale, RGBColor.White))

0 commit comments

Comments
 (0)