Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ooKriangsaKoo committed Nov 24, 2017
2 parents 6a3290c + de3fc1e commit c84d981
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue16.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.IO;
using iTextSharp.text.pdf;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues
{
/// <summary>
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/16
/// </summary>
[TestClass]
public class Issue16
{
[TestMethod]
public void Verify_Issue16_CanBe_Processed()
{
var pdfFilePath = TestUtils.GetOutputFileName();
var stream = new FileStream(pdfFilePath, FileMode.Create);

var path = TestUtils.GetPdfsPath("issue16.pdf");
var reader = new PdfReader(path);
var stamper = new PdfStamper(reader, stream);

var form = stamper.AcroFields;

foreach (DictionaryEntry field in form.Fields)
{
Console.WriteLine(field.Key);
}

form.SetField("Text Field0", "Value 1");

stamper.Close();
reader.Close();
stream.Dispose();
}
}
}
49 changes: 49 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue17.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues
{
/// <summary>
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/17
/// </summary>
[TestClass]
public class Issue17
{
[TestMethod]
public void Verify_Issue17_CanBe_Processed()
{
var pdfDoc = new Document(PageSize.A4);

var pdfFilePath = TestUtils.GetOutputFileName();
var fileStream = new FileStream(pdfFilePath, FileMode.Create);
PdfWriter.GetInstance(pdfDoc, fileStream);

pdfDoc.AddAuthor(TestUtils.Author);
pdfDoc.Open();

var image = Image.GetInstance(TestUtils.GetImagePath("loa.jpg"));
image.WidthPercentage = 60;
image.Alignment = Element.ALIGN_RIGHT;

var table = new PdfPTable(numColumns: 3);
var cell = new PdfPCell(/*image: image, fit: false*/)
{
Colspan = 2,
//Border = 0,
HorizontalAlignment = Element.ALIGN_RIGHT
};
cell.AddElement(image);
table.AddCell(cell);
table.AddCell(new PdfPCell(new Phrase("Test...")));

pdfDoc.Add(table);

pdfDoc.Close();
fileStream.Dispose();

TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}
}
}
5 changes: 5 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public static string GetTxtPath(string fileName)
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "txt", fileName);
}

public static string GetPdfsPath(string fileName)
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "pdfs", fileName);
}

public static Font GetUnicodeFont(
string fontName, string fontFilePath, float size, int style, BaseColor color)
{
Expand Down
Binary file not shown.

0 comments on commit c84d981

Please sign in to comment.