【问题标题】:how to create pdf in hindi using asp.net如何使用asp.net在印地语中创建pdf
【发布时间】:2018-04-21 01:11:00
【问题描述】:

我正在使用 asp.net 创建一个 pdf。 我已经能够成功地用英语创建 pdf,但是当我以印地语获取数据时,它在 pdf 中显示为空白。 如何获取印地语数据?

这是我的代码:

protected void GenerateReport(object sender, EventArgs e)
{
    DataRow dr = GetData("SELECT * FROM plant_detail where id = " + ddlEmployees.SelectedItem.Value).Rows[0]; ;
    Document document = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
    Font NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);

    BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\ARIALUNI.TTF", BaseFont.IDENTITY_H, true);

    using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
    {
        PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
        Phrase phrase = null;
        PdfPCell cell1 = null;
        PdfPTable table = null;
        Color color = null;

        document.Open();

        //Header Table
        table = new PdfPTable(2);
        table.TotalWidth = 500f;
        table.LockedWidth = true;
        table.SetWidths(new float[] { 0.3f, 0.7f });

        //Company Logo
        cell1 = ImageCell("~/images/index.jpg", 30f, PdfPCell.ALIGN_CENTER);
        table.AddCell(cell1);

        string cellText = "कार्यालय";
        iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL);
        //Company Name and Address
        phrase = new Phrase();
        iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell(new Phrase(12, cellText, font));
        //phrase.Add(new Chunk("कार्यालय कलेक्टर रायपुर\n\n\n\n\n\n", FontFactory.GetFont("Arial", 16, Font.BOLD, Color.RED)));
       // phrase.Add(new Chunk("कार्यालय कलेक्टर रायपुर\n\n\n\n\n\n", FontFactory.GetFont("Arial", 16, Font.BOLD, Color.RED)));
        phrase.Add(new Chunk("\n", FontFactory.GetFont("Arial", 8, Font.NORMAL, Color.BLACK)));
        phrase.Add(new Chunk("\n", FontFactory.GetFont("Arial", 8, Font.NORMAL, Color.BLACK)));
        phrase.Add(new Chunk("", FontFactory.GetFont("Arial", 8, Font.NORMAL, Color.BLACK)));
        cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
        cell.VerticalAlignment = PdfCell.ALIGN_TOP;
        table.AddCell(cellText);
    }
}

【问题讨论】:

    标签: c# asp.net pdf itext hindi


    【解决方案1】:
    //phrase.Add(new Chunk("कार्यालय कलेक्टर रायपुर\n\n\n\n\n\n", FontFactory.GetFont("Arial", 16, Font.BOLD, Color.RED)));
    // phrase.Add(new Chunk("कार्यालय कलेक्टर रायपुर\n\n\n\n\n\n", FontFactory.GetFont("Arial", 16, Font.BOLD, Color.RED)));
    phrase.Add(new Chunk("\n", FontFactory.GetFont("Arial", 8, Font.NORMAL, Color.BLACK)));
    

    我在代码中没有看到印地语字体。您需要包含像 Mangal 这样的印地语字体来显示印地语内容。做一些研究,你可以免费下载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多