2

How we can write Unicode Hindi text in iTextSharp?

I want that text to be inserted into a PDF.

doc.Add(new Paragraph("\n\n\n\n\n\n"));
PdfPTable table16page7 = new PdfPTable(8);
table16page7.WidthPercentage = 100;
table16page10.AddCell(new PdfPCell(new Phrase(new Chunk("?kks"k.kk i=k", new Font(Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK)))) { Border = 0, Colspan =8, PaddingBottom = 2, PaddingTop = 2, HorizontalAlignment = Element.ALIGN_CENTER});

When I paste Hindi text in the above chunk it will give random characters like

?kks"k.kk i=k
ADyson
  • 57,178
  • 14
  • 51
  • 63
  • What are you using to edit your code? Visual Studio supports Unicode - it should just work. – Stevo Jul 27 '18 at 06:58
  • 1
    shows random characters in the IDE you use or in the resulting PDF? – Rafael Palomino Jul 27 '18 at 13:14
  • I have just solved problem by creating font for language which i want to insert and just used that font .But i require help of google transalator .i just translate english version of required language to language i want and copy that transalation from there to chunk. It Work for me – Mayur Waghulde Jul 30 '18 at 03:58

1 Answers1

0

By adding ARIALUNI.TTF to font folder which is in C drive-> Windows->Fonts

string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");

            //Create a base font object making sure to specify IDENTITY-H
            BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            Font NormalHindiFont = new Font(bf,10, Font.NORMAL);
            Font BoldHindiFont = new Font(bf, 10, Font.BOLD);
            Font SmallHindiFont = new Font(bf,8, Font.NORMAL);
            Font hindifont = new Font(bf, 7, Font.NORMAL);

That Hindi Unicode text is translation of text in round braces ( To be filled by employee after reading instruction overleaf. Two Postcard Size phtographs to be attached with the form. This form is free of cost)

table1page7.AddCell(new PdfPCell(new Phrase(new Chunk("घोषाना पत्र करमचार्यो द्वार भरा जययेगा फॉर्म के साथ पोस्टकार्ड अकर के दो फोटोग्राफ भी लगाये जाने चाईए फॉर्म भर्ने से पहली पीट प्रूथ प्रति दे गया है! हिदायत को भली भती पढ़ लेना चाएये!यह फार्म निसुलख है यह फॉर्म मुफ्त है", NormalHindiFont))) { Border = 0, PaddingBottom = 2, Colspan = 20, PaddingTop = 2, HorizontalAlignment = Element.ALIGN_LEFT });

It works for me Thankyou very much For your suggestion regarding my query