0

I'm trying to use a custom font with HtmlFragment in Aspose.pdf for .NET, but I'm not able to get it to work. I'm using the FontRepository.OpenFont function to load the font from a file, but it doesn't seem to be applied to the text in the HtmlFragment.

Here's my code in C#:

var _dataDir = @"C:\Users\akash.choubey\";
Document doc = new Document();
Page page = doc.Pages.Add();
var fontPath = _dataDir + "astmensh.otf";
HtmlFragment hf = new HtmlFragment("<p>this is text</p>");
hf.TextState = new TextState();
hf.TextState.Font = FontRepository.OpenFont(fontPath);
page.Paragraphs.Add(hf);
doc.Save(_dataDir + "output.pdf");

I've verified that the font file exists at the specified path, and I've also tried using a built-in font such as Times New Roman instead of a custom font using FontRepository.FindFont and that works fine.

Is there something I'm missing in order to use a custom font with HtmlFragment in Aspose.pdf?

  • Would you please make sure that you are using Aspose.PDF for .NET 23.3 as it is the latest version? In case you are still facing an issue, please create a post on the official Aspose.PDF support forum (https://forum.aspose.com/c/pdf/10) which is the right place for such discussions. We will assist you there accordingly. This is Asad Ali and I am Developer Evangelist at Aspose. – Asad Ali Apr 03 '23 at 21:12
  • @AsadAli we have already raised this issue - https://forum.aspose.com/t/apply-custom-font-in-htmlfragment-in-pdf/262486/5 they have created a bug, could you resolve this as soon as possible? – Akash Choubey Apr 04 '23 at 07:14
  • Sure, we have seen your post and a ticket has been associated with it. You will surely get updates there as soon as the ticket is resolved. – Asad Ali Apr 04 '23 at 20:42

0 Answers0