如何在C#中使用iTextSharp的创建与泰米尔字体的PDF文件? [英] How to Create PDF file with Tamil Font by using itextsharp in C#?

查看:130
本文介绍了如何在C#中使用iTextSharp的创建与泰米尔字体的PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通过传递TAMIL文本(印第安语之一)。所以,我已经安装AVVAIYAR.TTF(泰米尔语字体之一)字体为我的泰米尔语font.But当我运行创造了我们的C#应用​​程序的PDF文件下面提到的铂族金属,创建的P​​DF文件不包含任何泰米尔字体display.It显示空行,而不是泰米尔文...

we are creating pdf files in our C# application by passing TAMIL text(one of the indian language).So, I already installed AVVAIYAR.TTF(one of the tamil font) font for my tamil language font.But when i run the below mentioned pgm, the created pdf file does not contain any tamil font display.It shows empty lines instead of the tamil text...

C#code:

Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"C:\pdfout.pdf", FileMode.Create));
document.Open();

PdfContentByte pcb = writer.DirectContent;
Font ft = new Font();
FontFactory.Register(@"C:\WINDOWS\Fonts\AVVAIYAR.TTF", "AVVAIYAR");
ft = FontFactory.GetFont("AVVAIYAR");

Paragraph pr1 = new Paragraph("இது முதல் பேரா", ft);
Paragraph pr2 = new Paragraph("This is a Sub Paragraph");
Paragraph pr3 = new Paragraph("This is the Second Paragraph");

document.Add(pr1);
document.Add(pr2);
document.Add(pr3);
document.Close();

我的输出PDF文件是:

<blank line>
This is a Sub Paragraph
This is the Second Paragraph

和我也有支持一些印第安人的语言来创建PDF文件。

And also i have to support some more indian languages to create the PDF files.

推荐答案

我已经把一个参考ARIALUNI.TTF.I试过这样的,

I have put a reference to ARIALUNI.TTF.I tried like this,

string fontpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\ARIALUNI.TTF"; 
BaseFont basefont = BaseFont.CreateFont(fontpath, BaseFont.IDENTITY_H, true);
Font font = new iTextSharp.text.Font(basefont, 24, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLUE);
Paragraph pr1 = new Paragraph("இது முதல் பேரா", AVVAIYARFont);

所以,现在泰米尔语字体显示在PDF file.But简约不简单的拼写错误...所以我在做一些读关于这个问题...

So, now tamil font is displayed in the pdf file.But simple simple spelling mistake... so i am doing some read on that issue...

这篇关于如何在C#中使用iTextSharp的创建与泰米尔字体的PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆