|
| 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 | +} |
0 commit comments