We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to select custom font

Hello Everyone,

Our software utilizes Aspose.Pdf to produce all print output and we experience issues if we attempt printing with font (TrueType) other than the 14 standard fonts provided by Aspose. We set the TextInfo.FontName to the name of our font (MICR E13B Match) however the text is printed in Arial. I made sure I have the font installed on my PC by opening Wordpad and using the font in question to write text and print.
Does anyone know how to use custom fonts with Aspose? Thank you in advance for your help.

Marian




Hi Marian,

Here is the c# sample which can help utilize the custom fonts in your pdf.

//Instantiate Pdf instance by calling it empty constructor
Pdf pdf1 = new Pdf();

//Create a section in the Pdf object
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Create a text paragraph inheriting text format settings from the section
Text text1 = new Text(sec1);

//Add the text paragraph to the section
sec1.Paragraphs.Add(text1);

//Create a text segment
Segment s1 = new Segment(" This is a sample text using Custom font");

//Set the font name to the TextInfo.FontName property of segment, where ‘Almonto Snow’ is custom font name
s1.TextInfo.FontName = "Almonte Snow";

// Set the value for property to include the font description into Pdf file
s1.TextInfo.IsFontEmbedded = true;

//Add the text segment to the text paragraph
text1.Segments.Add(s1);

//Save the Pdf
pdf1.Save(@"C:\ Font_Embeded.pdf");

Please also try to use following two properties for Truetype font, if it contains Unicode.

TextInfo.TruetypeFontFileName Property

Pdf.TruetypeFontMapPath Property

If it doesn't solve your problem, please a little more details about the issue, and also any sample files to help us investigate the issue in rather detail at our end.

Regards,

Dear Shahzad,

Thank you for your response. I did not have the IsFontEmbedded property set to true. Setting the IsFontEmbedded to true resolved font issue while I run it on my PC (WXP 32bit) however the same program/report is also launched by a report service (W2K3 64bit) and the printout does not print the custom font.
I run ProcessMonitor on the report server while my report was executing in order to find out if the application even tries accessing the correct font. ProcessMonotor recorded the application was reading the correct font file however the resulting PDF file used Arial font instead of the custom font. Any suggestions?
Thank you for your time.

Marian

Hi Marian,

We're looking into the matter and will investigate the issue at our end. We'll let you know about the resolution the earliest possible.

Could you please share the sample files as well?

Regards,

Hi Marian,

Please try adding the following code and let us know if it works:

pdf.IsTruetypeFontMapCached = true;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

pdf.TruetypeFontMapPath = somefolder;

pdf.SetUnicode();

pdf.Save(..);