[英]Bangla Font is not showing in ubuntu .net6
在 windows 處,字體顯示完美,但在 ubuntu 處顯示為方框。 我已經附上了 pdf。
我將 iTextSharp 用於 PDF 並且地址本身就是圖像。
這是代碼
if (!string.IsNullOrEmpty(shippingAddressData.Address1))
{
if (String.IsNullOrEmpty(shippingAddressData.Address2))
{
var customercityStateZipCountry = await FormatAddressTextAsync(shippingAddressData);
shippingAddress1 = shippingAddress1 + indent + "Address: " + shippingAddressData.Address1 + customercityStateZipCountry;
}
var customerAddress1Split = Split(shippingAddress1, 43);
int i = 0;
foreach (var customerAddress1BreakDown in customerAddress1Split)
{
if (i == 0)
{
var customerAddress1InBitMap = ConvertToBitMapDefault(customerAddress1BreakDown, 22f);
Image customerAddress1InImage = Image.GetInstance(customerAddress1InBitMap, System.Drawing.Imaging.ImageFormat.Jpeg);
shippingAddressPDF.AddCell(customerAddress1InImage);
}
else
{
var secondLine = indent + customerAddress1BreakDown;
var customerAddress1InBitMap = ConvertToBitMapDefault(secondLine, 22f);
Image customerAddress1InImage = Image.GetInstance(customerAddress1InBitMap, System.Drawing.Imaging.ImageFormat.Jpeg);
shippingAddressPDF.AddCell(customerAddress1InImage);
}
i++;
}
}
支撐方式
public System.Drawing.Bitmap ConvertToBitMapDefault(string Text, float fontSize = 22f, int widthPoint = 0)
{
//string familyName = _fileProvider.Combine(_fileProvider.MapPath("~/App_Data/Pdf/"), "ARIALUNI.ttf");
//Path.Combine(CommonHelper.MapPath("~/App_Data/Pdf/"), "ARIALUNI.ttf");
string familyName = _fileProvider.Combine(_fileProvider.MapPath("~/App_Data/Pdf/"), _pdfSettings.FontFileName);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(850, 40, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
bitmap.SetResolution(500f, 200f);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage((System.Drawing.Image)bitmap);
graphics.Clear(System.Drawing.Color.White);
graphics.DrawString(Text ?? "", new System.Drawing.Font(familyName, fontSize, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.InfoText,
(System.Drawing.PointF)new System.Drawing.Point(widthPoint, 3));
return bitmap;
}
請使用System.Web.HttpUtility.UrlEncode
對代碼中的字符進行編碼,如下所示。 它對我有用,它應該對你有用。
string Address1= shippingAddressData.Address1;
Address1 = System.Web.HttpUtility.UrlEncode(Address1, System.Text.Encoding.UTF8)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.