PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

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

Open YukeshM opened this issue 2 years ago • 0 comments

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 = <div> <div style='font-family: fantasy; font-weight: 600;'>36</div> </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)?

YukeshM avatar Nov 21 '23 02:11 YukeshM