Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Font thai , fix from LibrePDF/OpenPDF#57 #18

Merged
merged 5 commits into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: csharp
dist: trusty
mono: none
dotnet: 2.0.0
install:
- dotnet restore
script:
- dotnet build
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
iTextSharp.LGPLv2.Core
======================
[![Build Status](https://travis-ci.org/ooKriangsaKoo/iTextSharp.LGPLv2.Core.svg?branch=master)](https://travis-ci.org/ooKriangsaKoo/iTextSharp.LGPLv2.Core)

`iTextSharp.LGPLv2.Core` is an **unofficial** port of the last [LGPL version](http://www.gnu.org/licenses/old-licenses/lgpl-2.0-standalone.html) of the [iTextSharp (V4.1.6)](https://github.com/itextsharper/iTextSharp-4.1.6) to .NET Core.


Expand Down
6 changes: 5 additions & 1 deletion iTextSharp.LGPLv2.Core.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E1497710-C7C1-41AA-BA94-51108025D003}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{709790D7-8819-4E13-88F4-EE8392D81C1D}"
ProjectSection(SolutionItems) = preProject
.travis.yml = .travis.yml
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
Expand Down Expand Up @@ -37,4 +38,7 @@ Global
{3F68EB26-68BE-4724-B3F5-B4A0DEE70E65} = {E1497710-C7C1-41AA-BA94-51108025D003}
{18B7CBFD-5836-4338-B2E5-99742445504C} = {E1497710-C7C1-41AA-BA94-51108025D003}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0116F277-7713-4C01-B5BA-6E08E5264B2D}
EndGlobalSection
EndGlobal
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.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,17 @@ public RandomAccessFileOrArray(string filename, bool forceRead)
}
else
{
Stream isp = BaseFont.GetResourceStream(filename);
//Stream isp = BaseFont.GetResourceStream(filename);
Stream isp = null;
if ("-".Equals(filename))
{
isp = ((StreamReader)Console.In).BaseStream;
}
else
{
isp = BaseFont.GetResourceStream(filename);
}

if (isp == null)
throw new IOException(filename + " not found as file or resource.");
try
Expand Down