Skip to content

Commit

Permalink
Verify_Issue38_CanBe_Processed
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed May 10, 2019
1 parent 3ed6b28 commit 2dee49a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue37.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.IO;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
46 changes: 46 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue38.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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/38
/// </summary>
[TestClass]
public class Issue38
{
[TestMethod]
public void Verify_Issue38_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 swiss721BT = TestUtils.GetUnicodeFont("SWIS721 BT", TestUtils.GetFontPath("Swiss721BT.ttf"),
20, Font.NORMAL, BaseColor.Blue);

var swiss721ThinBT = TestUtils.GetUnicodeFont("SWIS721 Th BT", TestUtils.GetFontPath("Swiss721ThinBT.ttf"),
20, Font.NORMAL, BaseColor.DarkGray);

var text = new Phrase("Default font")
{
new Chunk("\nSwiss721BT", swiss721BT),
new Chunk("\nSwiss721ThinBT", swiss721ThinBT)
};

pdfDoc.Add(text);

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

TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}
}
}
13 changes: 9 additions & 4 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,29 @@ public static string GetPosterPath(string fileName)
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "posters", fileName);
}

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

public static string GetTahomaFontPath()
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "tahoma.ttf");
return GetFontPath("tahoma.ttf");
}

public static string GetArialUnicodeMSFontPath()
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "arialuni.ttf");
return GetFontPath("arialuni.ttf");
}

public static string GetSimSunFontPath()
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "simsun.ttf");
return GetFontPath("simsun.ttf");
}

public static string GetThaiFontPath()
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "thsarabunnew.ttf");
return GetFontPath("thsarabunnew.ttf");
}

public static string GetTxtPath(string fileName)
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 2dee49a

Please sign in to comment.