[英]Bangla Font is not showing in ubuntu .net6
At windows, the font is showing perfectly but at ubuntu is showing as the box.在 windows 处,字体显示完美,但在 ubuntu 处显示为方框。 I have attached both pdf.我已经附上了 pdf。
I use iTextSharp for PDF and the address itself is an image.我将 iTextSharp 用于 PDF 并且地址本身就是图像。
Here is the code这是代码
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++;
}
}
The supporting method支撑方式
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;
}
Please encode characters in your code by using System.Web.HttpUtility.UrlEncode
, like below.请使用System.Web.HttpUtility.UrlEncode
对代码中的字符进行编码,如下所示。 It works for me and it should useful to you.它对我有用,它应该对你有用。
string Address1= shippingAddressData.Address1;
Address1 = System.Web.HttpUtility.UrlEncode(Address1, System.Text.Encoding.UTF8)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.