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

Free Support Forum - aspose.com

Problem using Adobe Postscript Type 1 Fonts

Hi,

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.FontName = “HelveticaNeueLT-Thin”;
textInfo.FontPfmFile = Constants.FONT_DIRECTORY_URI + “lte50257.pfm”;
textInfo.FontOutlineFile = Constants.FONT_DIRECTORY_URI + “lte50257.PFB”;
textInfo.FontEncodingFile = Constants.FONT_DIRECTORY_URI + “mappings\adobe\stdenc.txt”;
textInfo.FontEncoding = “stdenc”;
//textInfo.FontEncoding = “StandardEncoding”;
//textInfo.FontEncoding = “AdobeStandardEncoding”;

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.”

when calling pdf.Save().

Anybody got an idea ?

Hello Erwan,

Thanks for considering Aspose.

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.

Hello Erwan,

<?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.

Hi,

Just to let you know I have tried the CharterBT-Roman Font, works for me, sample.

Pdf pdf1 = new Pdf();

// Page Setup

pdf1.PageSetup.PageHeight = 500;

Section sec1 = pdf1.Sections.Add();

Text text1 = new Text(sec1, "This is a test");

text1.TextInfo.FontSize = 12;
text1.TextInfo.Alignment = AlignmentType.Justify;
text1.TextInfo.FontName = "CharterBT-Roman";
text1.TextInfo.FontAfmFile = @"D:\charter-1.0\charter-1.0\bchr.afm";
text1.TextInfo.FontOutlineFile = @"D:\charter-1.0\charter-1.0\bchr.pfb";
text1.TextInfo.IsFontEmbedded = true;

sec1.Paragraphs.Add(text1);

pdf1.Save(@"d:\FontTest.pdf");

Hello Erwan,

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.

Hello Nayyer,

The files are those AndyWatt used in his code : bchr.afm & bchr.pfb.

AndyWatt I've tested your code and I'm afraid the output font is Times Roman.

Adding pdf1.IsFontNotFoundExceptionThrown = true; , the pdf can't be created.

Have you tried with this line and are you sure the output is in CharterBT Roman ?

Thanks for trying anyway,

Erwan

Hi,

Yes I am sure that the output os CharterBT, works for bold, none bold, italic etc.. Try the following code :

Pdf pdf1 = new Pdf();

pdf1.PageSetup.PageHeight = PageSize.A4Height;
pdf1.IsFontNotFoundExceptionThrown = true;

Section sec1 = pdf1.Sections.Add();

Text text1 = new Text(sec1, "The is a test output for charter-font");

text1.TextInfo.FontSize = 36;
text1.TextInfo.Alignment = AlignmentType.Justify;
text1.TextInfo.FontName = "CharterBT-BoldItalic";
text1.TextInfo.FontAfmFile = @"D:\charter-1.0\charter-1.0\bchbi.afm";
text1.TextInfo.FontOutlineFile = @"D:\charter-1.0\charter-1.0\bchbi.pfb";
text1.TextInfo.IsFontEmbedded = true;

sec1.Paragraphs.Add(text1);

//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));

pdf1.Save(@"d:\HJ.pdf");
Process.Start(@"d:\HJ.pdf");

Now if you comment out the following it fails for some reason

//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));

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 :-)");

text1.TextInfo.FontSize = 12;
text1.TextInfo.Alignment = AlignmentType.Justify;
text1.TextInfo.FontName = "HelveticaNeueLT-Thin";
text1.TextInfo.FontAfmFile = @"D:\testing\fonts\LTE50257.afm";
text1.TextInfo.FontOutlineFile = @"D:\testing\fonts\LTE50257.pfb";
text1.TextInfo.IsFontEmbedded = true;

sec1.Paragraphs.Add(text1);

//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));

pdf1.Save(@"d:\Helv.pdf");
Process.Start(@"d:\Helv.pdf");

Let me know if it works for you, see attachment.

Regards

Andy

Hi Andy,

Surprisingly for me.... it does work.

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 !

Thanks Andy !

Erwan

Hello Andy/Erwin

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.

We apologize for your inconvenience.

Hello Erwan,

Thanks for your patience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I'm pleased to inform you that, the issue reported earlier PDFNET-9858 in this forum thread is resolved in the hotfix shared over this link.

Please try using it and in case you still face any problem or you've any further query, please feel free to contact.