Reputation: 11612
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();
my output pdf file is :
<blank line>
This is a Sub Paragraph
This is the Second Paragraph
And also i have to support some more indian languages to create the PDF files.
Upvotes: 2
Views: 6200
Reputation: 1
A viable alternative is Quest PDF.
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.PageColor(Colors.White);
page.DefaultTextStyle(x => x.FontSize(20));
page.DefaultTextStyle(x => x.FontFamily("Vijaya"));
page.Header()
.Text("தமிழ் PDF!")
.SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
page.Content()
.PaddingVertical(1, Unit.Centimetre)
.Column(x =>
{
x.Spacing(20);
x.Item().Text("தமிழ் (Tamil language) தமிழர்களினதும் தமிழ் பேசும் பலரின் தாய்மொழி ஆகும். தமிழ், உலகின் உள்ள முதன்மையான மொழிகளில் ஒன்றும் செம்மொழியும் ஆகும்.");
});
page.Footer()
.AlignCenter()
.Text(x =>
{
x.Span("பக்கம் ");
x.CurrentPageNumber();
});
});
})
.GeneratePdf("தமிழ்.pdf");
Upvotes: 0
Reputation: 26
Procees 1:
step 1:Go to http://software.nhm.in/services/converter website
step2:paste this word படிவம்-டி ஊதியம் சீட்டு /விடுப்பு அட்டை
step3:1.change the first drop down to Unicode , 2.change the second drop down to TAB
step5:click the button converter
step6.text will be alligned.
step 7:main process start from hear
1.change the second drop down to TSCII and click on convert.(dont panic no changes would exists)
2.now change the first drop down to Unicode automatticaly the tamil text would change to "ÀÊÅõ-Ê °¾¢Âõ º£ðÎ /Å¢ÎôÒ «ð¨¼";
3.copy the content and place it in notepad.
Process 2:
1.First download TSC-Sri.ttf(http://www.eaglefonts.com/download.php?action=zip&image_id=129859)
2.save or move it in c:\Windows\fonts
3.finally Pate the below code in the c# program
string fontpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\TSC-Sri.ttf";
BaseFont basefont = BaseFont.CreateFont(fontpath, BaseFont.IDENTITY_H, true);
iTextSharp.text.Font font = new iTextSharp.text.Font(basefont, 24, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLUE);
Paragraph pr1 = new Paragraph("ÀÊÅõ-Ê °¾¢Âõ º£ðÎ /Å¢ÎôÒ «ð¨¼ ", font);
4.run the itextsharp pdf program output as excepted 100% working.
Upvotes: 1
Reputation: 11612
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);
So, now tamil font is displayed in the pdf file.But simple simple spelling mistake... so i am doing some read on that issue...
Upvotes: 1
Reputation: 5987
Can you please try the following code snippet?
string fontpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\AVVAIYAR.TTF";
BaseFont basefont = BaseFont.CreateFont(fontpath, BaseFont.IDENTITY_H, true);
Font AVVAIYARFont = new iTextSharp.text.Font(basefont, 24, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLUE); /*For test color blue is placed with some foramtting.*/
Paragraph pr1 = new Paragraph("இது முதல் பேரா", AVVAIYARFont);
This should work...
An out of the box thought, iText has not full support for all the indic languages at moment...See here they say that they dont have enough volunteers to support this.
Upvotes: 1