locked
How to create PDF document with urdu text using c#.net RRS feed

  • Question

  • User-1949221332 posted

    Hi all.

    I want to create a pdf document using c#.net. it is created very successfully and display english text correctly but when i changed text into URDU, then it does not display any thing.

    I am using "iTextSharp" library for creating PDF.

    so can any body tell me that is it possible to create a pdf with urdu text.

    Your quick response is highly appriciated.


    Regards,

    Ali bin zubair


    Thursday, July 30, 2009 7:57 AM

All replies

  • User1623436211 posted

    Refer to the following Link.

     http://forums.asp.net/p/1349626/2752650.aspx#2752650

     

    May this help you...

     

    Thursday, July 30, 2009 8:05 AM
  • User-1949221332 posted

    Hi,

    No brother this is not what i am lookinf for. i have created PDF document. following is the code.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using System.IO;

    namespace CreatePDF
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("iText Demo");

                // step 1: creation of a document-object
                Document myDocument = new Document(PageSize.A4.Rotate());
                try
                {

                    // step 2:
                    // Now create a writer that listens to this doucment and writes the document to desired Stream.

                    PdfWriter.GetInstance(myDocument, new FileStream("Salman.pdf", FileMode.Create));

                    Phrase footPhraseImg = new Phrase("Page: ", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL));
                    // step 3:  Open the document now using
                    myDocument.Open();

                    // step 4: Now add some contents to the document
                    myDocument.Add(new Paragraph("dfsdf"));
                    //میں پاکستان سے پیار کرتا ھوں
                }
                catch (DocumentException de)
                {
                    Console.Error.WriteLine(de.Message);
                }
                catch (IOException ioe)
                {
                    Console.Error.WriteLine(ioe.Message);
                }

                // step 5: Remember to close the documnet

                myDocument.Close();
            }
        }
    }


    But when i write urdu in following line

    myDocument.Add(new Paragraph("dfsdf"));

    It creates pdf document but did not display any thing.

    So how can i display urdu in pdf using c#.net





    Thursday, July 30, 2009 8:20 AM
  • User1101619677 posted

    Maybe try to set the font with urdu letters manually. For example for polish letters:

    BaseFont bfComic = BaseFont.CreateFont("c:\\windows\\fonts\\tahoma.ttf", BaseFont.CP1250, BaseFont.NOT_EMBEDDED); 
    iTextSharp.text.Font f=new iTextSharp.text.Font(bfComic,12); 
    document.Add(new Paragraph("Zażółć gęślą jaźń",f));



    Thursday, July 30, 2009 11:16 PM
  • User-1949221332 posted

    Maybe try to set the font with urdu letters manually. For example for polish letters:


    1. BaseFont bfComic = BaseFont.CreateFont("c:\\windows\\fonts\\tahoma.ttf", BaseFont.CP1250, BaseFont.NOT_EMBEDDED);   
    2. iTextSharp.text.Font f=new iTextSharp.text.Font(bfComic,12);   
    3. document.Add(new Paragraph("Zażółć gęślą jaźń",f));  
    BaseFont bfComic = BaseFont.CreateFont("c:\\windows\\fonts\\tahoma.ttf", BaseFont.CP1250, BaseFont.NOT_EMBEDDED); 
    iTextSharp.text.Font f=new iTextSharp.text.Font(bfComic,12); 
    document.Add(new Paragraph("Zażółć gęślą jaźń",f));





    Thanks for your reply. yes it works but did not fullfil my requirement. i want to show urdu text in PDF. and when i write URDU in paragraph string it displays question marks. it did not render urdu font.

    So is there anyyyyyyy way to display urdu text in PDF whily using c#.net.?????????

    Friday, July 31, 2009 1:23 AM
  • User-775866298 posted

    I have created the document in same way, but when trying to open it. The file shows the error message "There was an error opening this document. This file is already open or in use by another application."


    i have properly close the document as "doc.Close();"

    Thursday, March 25, 2010 5:42 AM
  • User-1949221332 posted

    Hi..

    Try to kill your process in Task manager. Might be you close properly but windows did not close process completely.


    Tuesday, April 6, 2010 3:48 AM