gpt4 book ai didi

c# - 如何使用 asp.net 在印地语中创建 pdf

转载 作者:行者123 更新时间:2023-11-30 12:55:40 29 4
gpt4 key购买 nike

我正在使用 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);
}
}

最佳答案

//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 等印地语字体才能显示印地语内容。做一些研究,您可以免费下载。

关于c# - 如何使用 asp.net 在印地语中创建 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47178167/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com