ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.08k stars 237 forks source link

Couldn't able to add custom font family and font weight #410

Open YukeshM opened 1 year ago

YukeshM commented 1 year ago

I'm trying to add custom font family and font weight in the inline html. But I couldn't able to see any changes in the generated pdf.

var htmlContent = `

36
            </div>`;

PdfDocument pdfDoc = new PdfDocument(); PdfGenerator.AddPdfPages(pdfDoc, htmlContent, PageSize.A4); using (MemoryStream ms = new MemoryStream()) { pdfDoc.Save(ms); response = ms.ToArray(); string fileName = "D:\downloads\pdf\" + DateTime.Now.Ticks + ".pdf"; File.WriteAllBytes(fileName, response); }

In the above code. I'm trying to convert html to pdf and save in my local machine. But the resulted pdf doesn't applied font-family and font-weight. Can anyone help me to sort out the issue? Is there any documentation or example for how to use custom font family (ex: Fantasy)?