I’m currently evaluating Aspose.Pdf and as for now it had all the functionalities I need. Until I tried to generate a Pdf using Postscript Type 1 fonts. I tried setting TextInfo’s members with a lot of different options, no success.
One of the fonts I’m trying to use is “HelveticaNeueLT-Thin”, it lies in PFM and PFB files that I attached to this thread in a zip file for testing).
Here’s how I set the font in my code [C#] :
textInfo being the TextInfo object of the Text object i want to set the font for.
Access to the files is correct and has been tested by opening the files in streams.
As you can see, I have tried with several font encoding names (not to mention other encoding types like winansi, iso-8859-1, CP1250,…)
I got the mapping file from the unicode repository, you can get it there.
I also tried to use the CharterBT-Roman font as AFM/PFB with no luck…
I couldn’t try with Pipe-Dream cause this font is not available on the author’s site anymore and I couldn’t find it anywhere else (in Postscript Type 1 format).
By the way, using True Type and PDF Core Fonts works perfectly.
This is really the only issue preventing me to purchase Aspose.Pdf for my project so I hope we’ll find a way to solve it !
Thanks,
Erwan
Edit : To specify the error a bit more : text just displays in Times insted of
my Font, and throws an exception (when IsFontNotFoundExceptionThrown is
set to true of course) :
“The Font ‘HelveticaNeueLT-Thin’ is not found. This font is not supported.”
We are definitely looking into the details of this problem and will keep you updated with the status of correction. Please spare us little time and we will get back to you as soon as we have some solution regarding this problem.
Your patience and understanding is greatly appreciated in this regard. We apologize for any inconvenience that you have been facing in this regard.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
After thorough investigation and testing, we have found that this font is currently not supported by Aspose.Pdf. For the sake of correction, I've logged it in our issue tracking system as PDFNET-9858. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.
I've tested the scenario and I am afraid I'm unable to use the CharterBT-Roman font and the resultant PDF is in Times New Roman font. Can you please guide which file from the repository shared at CharterBT-Roman is to be installed.
I have also tried it for Helvetica as well, and it works.
Pdf pdf1 = new Pdf();
// Page Setup
pdf1.PageSetup.PageHeight = PageSize.A4Height; pdf1.IsFontNotFoundExceptionThrown = true; Section sec1 = pdf1.Sections.Add(); Text text1 = new Text(sec1, "This is a test with HelveticaNeueLT-Thin :-)");
//calculate the lines count int lineCount = (int)((text1.GetTextHeight(pdf1, pdf1.PageSetup.PageWidth - pdf1.PageSetup.Margin.Left - pdf1.PageSetup.Margin.Right)) / (text1.TextInfo.FontSize + text1.TextInfo.LineSpacing));
Text text2 = new Text(sec1, "This is a test with HelveticaNeueLT-Bold :-)"); text2.TextInfo.FontSize = 12; text2.TextInfo.Alignment = AlignmentType.Justify; text2.TextInfo.FontName = "HelveticaNeueLT-Bold"; text2.TextInfo.FontAfmFile = @"D:\testing\fonts\LTE50261.afm"; text2.TextInfo.FontOutlineFile = @"D:\testing\fonts\LTE50261.pfb"; text2.TextInfo.IsFontEmbedded = true;
sec1.Paragraphs.Add(text2);
//calculate the lines count int lineCount2 = (int)((text2.GetTextHeight(pdf1, pdf1.PageSetup.PageWidth - pdf1.PageSetup.Margin.Left - pdf1.PageSetup.Margin.Right)) / (text2.TextInfo.FontSize + text2.TextInfo.LineSpacing));
I tested using Pfm files instead of Afm (I don't have Afm files) with Helvetica Neue and it works great.
Like you pointed out, the trick is to use the GetTextHeight method.
I add text1.GetTextHeight(pdf1, 10); anywhere before saving the pdf document and the font is correctly utilized and embedded. Curiously though, the encoding is "Ansi" when looking in "File > Document > Fonts".
I will use this as a workaround in the meantime, but if Aspose support could find a way we could use those kind of fonts without using some black magic that'd be great !
I've tested the scenario using CharterBT-Roman font and I'm also surprised to see that when we call a method Text.GetTextHeight() the font is being embedded properly into resultant PDF document whereas, if we comment out this line, error message "Font is not supported" is displayed. The issue has been reported to the development team and they are looking into the details of this matter.
Andy, can you please share HelveticaNeueLT-Thin & HelveticaNeueLT-Bold font, so that we can also test the scenario using these files.