Skip to content

Commit

Permalink
add test font thai
Browse files Browse the repository at this point in the history
  • Loading branch information
ooKriangsaKoo committed Nov 24, 2017
1 parent e13eabd commit 6a3290c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
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 @@ -65,6 +65,11 @@ public static string GetSimSunFontPath()
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "simsun.ttf");
}

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

public static string GetTxtPath(string fileName)
{
return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "txt", fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,28 @@ public void Verify_Chinese_PDF_File_CanBeCreated()

TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}

[TestMethod]
public void Verify_Thai_PDF_File_CanBeCreated()
{
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 chinese = "ทดสอบ ภาษาไทย ฝีมือ พึ่ง พ่อ กู รู้ ดู กันต์ ก๋ยวเตี๋ยว";

var tahomaFont = TestUtils.GetUnicodeFont("THSarabunNew", TestUtils.GetThaiFontPath(), 20, Font.NORMAL, BaseColor.Black);
pdfDoc.Add(new Paragraph(chinese, tahomaFont));

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

TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}
}
}
Binary file not shown.

0 comments on commit 6a3290c

Please sign in to comment.