Hello,
I’m trying to use a Helvetica font in my PDF but it won’t work.
Here is what I’m using.
Text text1 = new Text(sec1, “this is text content”);
text1.TextInfo.FontSize = 11;
text1.TextInfo.FontName = “Helvetica-Condensed”;
text1.TextInfo.FontAfmFile = Server.MapPath(“Font/Helvetica Condensed/HVC_____.AFM”);
text1.TextInfo.FontOutlineFile = Server.MapPath(“Font/Helvetica Condensed/HVC_____.PFB”);
text1.TextInfo.FontEncodingFile = Server.MapPath(“Font/CP1250.TXT”);
text1.TextInfo.FontEncoding = “CP1250”;
text1.TextInfo.IsFontEmbedded = true;
sec1.Paragraphs.Add(text1);
What can be the problem?
Regards
Hello Bart,
Thanks for considering Aspose.
I've tested the scenario using Aspose.Pdf for .NET 4.1.1. and in my case I'm unable to notice the problem. The Helvetica Condensed font is properly being embedded into PDF document. I've tested the scenario with two font files i.e. Helvetica_Condensed.ttf and Helvetica_Condensed_Black_Se.ttf (they are also in attachment) and information of both font files is being included into PDF file. I've tested with the following code snippet.
[C#]
//Instantiate Pdf instance by calling its empty constructor\
Pdf pdf1 = new Pdf();
//Create a section in the Pdf document
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();
Text text1 = new Text(sec1, "this is text content");
text1.TextInfo.FontSize = 11;
text1.TextInfo.FontName = "Helvetica-Condensed-Black-Se";
// text1.TextInfo.FontName = "Helvetica Condensed";
// text1.TextInfo.IsFontEmbedded = true;
pdf1.SetUnicode();
sec1.Paragraphs.Add(text1);
//Save the Pdf document
pdf1.Save(@"d:/pdftest/Helvetica Condensed Black Se.pdf");
In my code snippet you would have noticed that I've used pdf1.SetUnicode(); instead of text1.TextInfo.IsFontEmbedded = true; because when using Pdf.SetUnicode(), the method only includes the font information where the font file is used rather than embedding the complete font file into PDF document in which the size of document is also increased. For more related information, I would suggest you to take a look over the following article Fonts embedding while creating PDF
The resultant PDF documents that I've generated are in attachment, please take a look. In case you still face any problem, please share the resource font files that you're using so that we can test them at our end.
We apologize for your inconvenience.
Thanks for the fast awnser.
How can I get the font without installing it on the server?
I use OTF fonts
Regards
Hello Bart,
I'm afraid you need to install the font over the machine/server generating PDF document, in case you need to include the font information inside PDF document.
Hello,
.ttf fonts work fine after installing but .otf (open type) not.
Is it possible to work with .otf fonts?
Regards
Hello Bart,
Sorry for replying you late.
I'm afraid OTF fonts are currently not supported. But, for the sake of correction, we've logged this requirement as PDFNET-13267 in our issue tracking system. But I'm afraid we might not be able to get this issue resolved in short time. As soon as we've made some significant progress, we would be pleased to update you with the status of correction.
Your patience and comprehension is greatly appreciated in this regard.
The issues you have found earlier (filed as PDFNEWNET-13267) have been fixed in Aspose.Pdf for .NET 10.3.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(7)