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

  • SEARCH
  • Home
  • 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 8322917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:32:44+00:00 2026-06-08T23:32:44+00:00

I like to convert GridView to PDF using iTextSharp.dll.However I have cyrillics characters in

  • 0

I like to convert GridView to PDF using iTextSharp.dll.However I have cyrillics characters in my GridView and they don’t appear in the pdf document.Here is the code I am using

        Response.Clear(); //this clears the Response of any headers or previous output
        Response.Buffer = true; //ma
        Response.ContentType = "application/pdf";
        iTextSharp.text.pdf.BaseFont arial = iTextSharp.text.pdf.BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", "Identity-H", iTextSharp.text.pdf.BaseFont.EMBEDDED);
        Response.AddHeader("content-disposition", "attachment;filename=Pregled.pdf");


        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        StringWriter sw = new StringWriter();

        HtmlTextWriter hw = new HtmlTextWriter(sw);

        gvTekovenKorisnik.RenderControl(hw);

        StringReader sr = new StringReader(sw.ToString());

        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);


        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

        pdfDoc.Open();

        htmlparser.Parse(sr);

        pdfDoc.Close();

        Response.Write(pdfDoc);

        Response.End();

I read that I have to change the baseFont but I don’t know where to put it in code after changing it.Can somebody help me?

  • 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-06-08T23:32:45+00:00Added an answer on June 8, 2026 at 11:32 pm

    I propose the following variant

    protected void btnGridViewToPdf_Click(object sender, EventArgs e)
        {
            GridViewToPdf();
        }
            private void GridViewToPdf()
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=Reestr.pdf");
                //подключаепм шрифт
                String FONT_LOCATION = Server.MapPath("~/fonts/arial.ttf");
                BaseFont baseFont = BaseFont.CreateFont(FONT_LOCATION, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font = new iTextSharp.text.Font(baseFont, iTextSharp.text.Font.DEFAULTSIZE, iTextSharp.text.Font.NORMAL);
                //подключили
                //создаем PDF документ
                Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);  
                pdfDoc.Open();
                //Создадим таблицу 
                PdfPTable table = new PdfPTable(2);
                //Создадим заголовок
                table.AddCell(new PdfPCell(new Paragraph("\nРеестр закупок\n\n", font)) { Colspan = 2, HorizontalAlignment=1 });
                //столбцы шириной в пропорции - 1/15 и 14/15
                float[] widths = new float[] { 1f, 14f };
                table.SetWidths(widths);
                //оставлять зазор до и после таблицы
                table.SpacingBefore = 10f;
                table.SpacingAfter = 10f;
                PdfPCell cell = new PdfPCell(new Phrase());
                cell.Padding = 5;
                cell.Colspan = 3;
                foreach (GridViewRow row in GridView1.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        Label _lblN = row.FindControl("lblN") as Label;
                        String lblN = _lblN.Text.ToString();
                        Label _lblnameOrder = row.FindControl("lblnameOrder") as Label;
                        String lblnameOrder = _lblnameOrder.Text.ToString();
                        Label _lblsummaOrder = row.FindControl("lblsummaOrder") as Label;
                        String lblsummaOrder = _lblsummaOrder.Text.ToString();
    
                        ///
                        PdfPCell cell1 = new PdfPCell(new Phrase(lblN, font)) { HorizontalAlignment = 1, VerticalAlignment= 1 };
                        table.AddCell(cell1);
                        ///
    
                        //table.AddCell(new PdfPCell(new Paragraph(lblN, font)) { HorizontalAlignment = 1 });
    
                        table.AddCell(new PdfPCell(new Paragraph("Наименование закупки: \n" + lblnameOrder + "\nСумма: \n" + lblsummaOrder, font)));
                    }
                }
                pdfDoc.Add(table);
                pdfDoc.Close();
                Response.End();
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working with a gridview and would like to convert my total
I would like to convert numbers to the shorter form using NSNumberFormatter . For
I have gridview in my asp.net 3.5 application [C#]. Which looks like this: <asp:GridView
I have a gridview with the onRowDeleting method implemented. I would like to prompt
I was using Gridview for a while now and I have noticed that its
I have a webforms project using EF codefirst to persist data. I'd like to
I have a gridview and I'd like to summarise data in it and I
I'm guessing it needs to be something like: CONVERT(CHAR(24), lastModified, 101) However I'm not
I'm using the tableToGrid method of jqGrid to convert an ASP.Net GridView into a
I have a report like page which displays a gridview and a chart created

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.