Skip to content

Commit 9808656

Browse files
committed
Add tests for issue-177
1 parent dcbf960 commit 9808656

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.IO;
2+
using iTextSharp.text.pdf;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
5+
namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues;
6+
7+
/// <summary>
8+
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/177
9+
/// </summary>
10+
[TestClass]
11+
public class Issue177
12+
{
13+
[TestMethod]
14+
public void Test_Issue177_Verify_PdfReader_Works()
15+
{
16+
var inputFile = TestUtils.GetPdfsPath(fileName: "issue177.pdf");
17+
18+
using var reader = new PdfReader(inputFile);
19+
Assert.AreEqual(expected: 1, reader.NumberOfPages);
20+
}
21+
22+
[TestMethod]
23+
public void Test_Issue177_Verify_PdfStamper_Works()
24+
{
25+
var inputFile = TestUtils.GetPdfsPath(fileName: "issue177.pdf");
26+
using var outStream = new FileStream(TestUtils.GetOutputFileName(), FileMode.Create);
27+
PdfReader.AllowOpenWithFullPermissions = true;
28+
using var pdfReader = new PdfReader(inputFile);
29+
using var pdfStamper = new PdfStamper(pdfReader, outStream);
30+
31+
var box = pdfReader.GetPageSize(index: 1);
32+
var canvas = pdfStamper.GetOverContent(pageNum: 1);
33+
canvas.SetRgbColorStroke(red: 255, green: 0, blue: 0);
34+
canvas.MoveTo(box.Left, box.Bottom);
35+
canvas.LineTo(box.Right, box.Top);
36+
canvas.MoveTo(box.Right, box.Bottom);
37+
canvas.LineTo(box.Left, box.Top);
38+
canvas.Stroke();
39+
}
40+
}
Binary file not shown.

0 commit comments

Comments
 (0)