1

We are using Proxima Nova fonts (specifically, Proxima Nova Condensed regular) in our MVC .NET project, but they will not embed properly in the PDF output. When looking at the PDF properties, I see "ProximaNovaCond-Regular (Embedded)" listed, and the icon next to it looks like a page with a gray "F" on it. I also see Arial Narrow and Arial Narrow, Bold listed with "(Embedded Subset)", and the document seems to be defaulting to these.

I'm not using @font-face in the CSS, but rather doing this:

font-family: "Proxima Nova Cn Rg", "Proxima Nova Cond", "Proxima Nova Condensed";

In the controller function that generates the pages, there is this code:

var targetDocument = CreateNewDoc(orientation, paperSize);
targetDocument.HtmlOptions.FontEmbed = true;
targetDocument.HtmlOptions.FontSubset = false;
targetDocument.HtmlOptions.FontSubstitute = false;
targetDocument.HtmlOptions.FontProtection = false;
targetDocument.Font = targetDocument.EmbedFont(Server.MapPath("\\Content\\fonts\\proxima-nova\\ProximaNova-Reg-webfont.ttf"));
targetDocument.Font = targetDocument.EmbedFont(Server.MapPath("\\Content\\fonts\\proxima-nova\\ProximaNova-Sbold-webfont.ttf"));

If the project is run locally, the fonts seem to work, but not on the server. The fonts are installed on the server. Is there anything we might be missing with the fonts or how we embed them? I looked at several different other questions on here regarding font embedding but none of them offered any solutions for our situation. I'm not sure what other information to provide here, but let me know what might be needed to answer my question and I'll find it.

Edit: I could have sworn I updated this... Apologies to the responders. Unfortunately I can not accept any of the answers as correct as we were never able to resolve the issue.

pWEN
  • 15
  • 7
  • 1
    How did you installed that fonts on server? – Morcilla de Arroz Sep 28 '15 at 10:17
  • Hi - I have a similar issue. Diff tech environmane as I am using ActiveX DLL's under comm, but the same as I seek to add a 'private' font from specific path. DLL can access the font and produce accurate glyphs in a bitmap generated from the DLL at same time as PDF, but PDF contains Times New Roman instead of intended font. System was fine on Win2008 - issue occurs after migration to Win2012. Did you solve your issue ? – Vanquished Wombat Mar 31 '17 at 07:12

2 Answers2

0

You can either have the fonts embedded using simply their name, or you can dynamically load them from file. You appear to be trying to do the latter, but that is not working. What I would do:

  • Check the path after Server.MapPath() and that the file is actually there, and you have access to it from your app.
  • As you say you have the fonts installed on the server, you could simply try using the full name of the font. Make sure they actually are installed properly first and that you are using the correct name.
monty
  • 1,543
  • 14
  • 30
-1

For the first parameter of targetDocument.EmbedFont, you need to specify the font typeface, not the physical path to the font.

e.g.

targetDocument.EmbedFont("Arial Regular");

To get the correct type face name, go to Control Panel\All Control Panel Items\Fonts in explorer. Find your font. You need to specify the font face, not the font family. e.g. for Arial, specify "Arial Bold" or "Arial Regular".

You can check if your font is returned correctly by checking that the return value of EmbedFont is non zero.

AntonK
  • 2,303
  • 1
  • 20
  • 26
  • This is not true, from abcpdf docs: "If you need to dynamically load a font you can pass this method a path to your font file." – monty Jun 02 '16 at 23:00
  • Thanks, for the correction. I did not see this in the docs. I'll certainly try it out. – AntonK Jun 08 '16 at 01:55