提问人:Ahmed Hassan 提问时间:11/15/2023 最后编辑:CharliefaceAhmed Hassan 更新时间:11/15/2023 访问量:22
无法使用 PdfSharpCore 从我的 dotnet core 6 中的数据库中获取乌尔都语数据
Unable to get Urdu data from database in my dotnet core 6 using PdfSharpCore
问:
我正在尝试获取包含特定用户数据的 Pdf 表单,例如姓名、年龄、出生日期、注册号等,以英语或日期存储的数据很好,就像乌尔都语中显示为矩形框的名称和地址一样
我的后端代码:
using PdfSharpCore;
using PdfSharpCore.Pdf;
using TheArtOfDev.HtmlRenderer.PdfSharp;
using PdfSharpCore.Fonts;
using PdfSharpCore.Utils;
using PdfSharpCore.Drawing;
[HttpGet("{serialNo}")]
public async Task<IActionResult> GenerateNotificationsPdfForm(string serialNo)
{
Notifications notification = await repository.GetNotificationReport(serialNo);
JsonElement json = notification.Params.RootElement;
Member member = await memberRepository.Get(json.GetProperty("MemberId").GetInt32());
NotificationPdfModel data = new()
{
FullName = member.FullName,
RegistranNumber = member.RegistrationNumbers.Where(r => r.Current).Select(s => s.Code).FirstOrDefault(),
FatherName = member.FatherName,
Dob = member.DateOfBirth,
Education = member.MemberEducations.Select(s => s.SetupEducations.Degree).FirstOrDefault(),
Occupation = member.MemberOccupations.Select(s => s.SetupOccupations.Name).FirstOrDefault(),
MaritalStatus = member.MemberMaritalStatuses.Select(s => s.SetupMaritalStatus.Name).FirstOrDefault(),
ContactNo = string.Join(",", memberRepository.GetMemberMobileNumbers(member)),
PreviousAddress = memberRepository.GetMemberCurrentAddress(member),
ResponsibilityName = member.MemberResponsibilities.Where(mr => mr.Current).Select(s => s.DisplayName).FirstOrDefault(),
MubtadiCourse = member.CourseParticipants.Where(cp => cp.Course.Published && cp.Course.CourseType.StaticType == CourseType.StaticCourseTypes.MubtadiTarbiyatiCourse).Select(cp => new MemberCourseModel(){
StartDate = cp.Course.StartDate,
Location = cp.Course?.Address ?? cp.Course?.CourseLocation?.Address,
}).FirstOrDefault(),
MultazimCourse = member.CourseParticipants.Where(cp => cp.Course.Published && cp.Course.CourseType.StaticType == CourseType.StaticCourseTypes.MultazimTarbiyatiCourse).Select(cp => new MemberCourseModel(){
StartDate = cp.Course.StartDate,
Location = cp.Course?.Address ?? cp.Course?.CourseLocation?.Address,
}).FirstOrDefault(),
NisabBaraEMutaliya = json.GetProperty("NisabBaraEMutaliya").GetString(),
TaluqMaAllah = json.GetProperty("TaluqMaAllah").GetString(),
SamaOTaat = json.GetProperty("SamaOTaat").GetString(),
SamaOBasar = json.GetProperty("SamaOBasar").GetString(),
InfradiDawat = json.GetProperty("InfradiDawat").GetString(),
JihadBilMaal = json.GetProperty("JihadBilMaal").GetString(),
};
var document = new PdfDocument();
string HtmlContent = "<h1>"+data.Dob.Value.ToString("dd-MM-yyyy")+"</h1>";
HtmlContent += "<h1 style='font-family: Alvi Nastaleeq;'>"+data.FullName+"</h1>";
PdfGenerator.AddPdfPages(document, HtmlContent, PageSize.A4);
byte[] response = null;
using (MemoryStream ms = new MemoryStream())
{
document.Save(ms);
response = ms.ToArray();
}
string FileName = "Test.pdf";
return File(response, "application/pdf", FileName);
}
答: 暂无答案
评论