Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 338269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:24:49+00:00 2026-05-12T10:24:49+00:00

I want to export gridview to pdf by using the itextsharp library. The problem

  • 0

I want to export gridview to pdf by using the itextsharp library. The problem is that some turkish characters such as İ,ı,Ş,ş etc… are missing in the pdf document. The code used to export the pdf is:

 protected void LinkButtonPdf_Click(object sender, EventArgs e)
    {
        Response.ContentType = "application/pdf";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        System.IO.StringWriter stringWrite = new StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        GridView1.RenderControl(htmlWrite);
        StringReader reader = new StringReader(textConvert(stringWrite.ToString()));
        Document doc = new Document(PageSize.A4);
        HTMLWorker parser = new HTMLWorker(doc);
        PdfWriter.GetInstance(doc, Response.OutputStream);
        doc.Open();
        parser.Parse(reader);
        doc.Close();
    }
    public static string textConvert(string S)
    {
        if (S == null) { return null; }
        try
        {
            System.Text.Encoding encFrom = System.Text.Encoding.UTF8;
            System.Text.Encoding encTo = System.Text.Encoding.UTF8;
            string str = S;
            Byte[] b = encFrom.GetBytes(str);
            return encTo.GetString(b);
        }
        catch { return null; }
    }

Note: when I want to insert characters into the pdf document, the missing characters are shown in it. I insert the characters with this code:

   BaseFont bffont = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
        Font fontozel = new Font(bffont, 12, Font.NORMAL, new Color(0, 0, 0));
        doc.Add(new Paragraph("İİııŞŞşşĞĞğğ", fontozel));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:24:50+00:00Added an answer on May 12, 2026 at 10:24 am

    Finaly I think I found the solution,I changed itextsharp source code a little in order to show turkish characters.(turkish character code is cp1254)

    I add "public const string CP1254 = "Cp1254";" to [BaseFont.cs] in the source code.

    After that I modify the [FactoryProperties.cs].I changed like this;

    public Font GetFont(ChainedProperties props)
    {
    I don't write the whole code.I changed only code below;
    ------------Default itextsharp code------------------------------------------------------
      if (encoding == null)
                    encoding = BaseFont.WINANSI;
                return fontImp.GetFont(face, encoding, true, size, style, color);
    -------------modified code--------------------------------------------
    
                encoding = BaseFont.CP1254;
                return fontImp.GetFont("C:\\WINDOWS\\Fonts\\arial.ttf", encoding, true, size, style, color);
    }
    

    .After I compile new dll ,and missing characters are shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 215k
  • Answers 215k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For official “JavaScript”, that is Mozilla's implementation of ECMA-262, you… May 12, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer Yahoo Finance lets you export their data. For a ticker,… May 12, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer I didn't really ever get around to solving this question,… May 12, 2026 at 10:56 pm

Related Questions

Does anyone have an example (code or a link) that will allow me to
I have a huge IQueryable that I want to export directly to Excel for
I have a page with a button that when I click, it retrieves data
I have a GridView inside of a User Control populated from a List of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.