5

I'm currently fighting with an issue of styling. I am creating a PDF using IronPDF and generating the new PDF from HTML.

I have an instance where my fonts are being overridden. The style is the following:

.bbBlankPage {
    font-size: 20px; /*14 pt*/
    text-align: center;
    font-family: Arial !important;
    font-weight: bold;
    padding-top: 55%;
    text-indent: 40px;
}

When the HTML is generated and spit out into the PDF, the PDF shows the font as ArialBold. This is causing an issue with the font looking smaller and scrunched up in comparison to the original. I'm trying to overcompensate by enlarging the font size but the change in font family has me stumped. If I remove font-weight, it becomes ArialRegular, which isn't right either. I just want normal Arial font.

IyaTaisho
  • 863
  • 19
  • 42
  • 2
    Did you try to add font-style: normal; font-variant: normal; font-weight: bold; ? – MaxiGui Sep 02 '20 at 20:20
  • Yes, I did try those. I spoke with IronPDF about the issue also and found out that it is a known issue too. They are looking into how to deal with it. – IyaTaisho Sep 03 '20 at 14:01
  • Any update? I am having issues with fonts too. – Mike Sep 14 '20 at 21:34
  • @Mike I spoke with IronPDF and they have not solved the issue yet. They are aware of this problem and are working to resolve it. Hopefully they do so in the near future. – IyaTaisho Sep 15 '20 at 13:34

2 Answers2

2

I work for IronSoftware as a support engineer.

Try using a local font by importing it from a folder instead of using the system font installed on the system. This isn't perfect though gives a better result.

Code example below references Arial:

<style type="text/css">
@font-face {
font-family: 'Arial';
src: url('./Arial.eot');
src: local('Arial'), url('./Arial.woff') format('woff'), url('./Arial.ttf') format('truetype');
}
.fontsforweb_fontid_1080 {
font-family: 'Arial' !important;
}
</style>

This issue will be resolved with a new rendering engine we are building for release in the first half of 2021.

darren
  • 475
  • 4
  • 15
  • Thank you for letting me know. I know a new release came out at the end of November that seemed to help a bit too. The font looks slightly smaller still but isn't near as scrunched up. I'll try your suggestion to see if that helps. Thanks! – IyaTaisho Dec 07 '20 at 14:32
  • 2
    2021 and I still have the same problem. I use an imported font and when I'm debugging it looks acceptable I guess but once deployed on an Azure App Service it looks awful. Really poor quality. I've tried playing with the DPI option to no end... – user2509192 Mar 23 '21 at 17:29
  • Try the EAP for the new Chrome rendering engine. This is currently beta so is Windows-only with Linux and *nix support expected in June https://www.nuget.org/packages/IronPdf.EAP/ – darren May 28 '21 at 02:33
  • I'm also testing IronPDF and ran into the same problem. Your solution here doesn't work though. Also, couldn't use EAP because I got an error (can't tell you which one at the moment because I had to use the released version) – splattne Jun 07 '21 at 15:09
  • 1
    The IronPdf.EAP 2021.6.3 update resolved a deployment issue so give it another try, as everyone that has tried it has reported kerning issues are fully resolved. Now supports Linux with Mac support planned for the next update. https://www.nuget.org/packages/IronPdf.EAP/ – darren Jul 19 '21 at 07:27
  • IronPdf 2020.9 resolves this for my team. No need to use EAP anymore. https://www.nuget.org/packages/IronPdf/ – Stephanie Oct 07 '21 at 03:10
1

Kerning is working for me well after the 2021.9 update of IronPDF

I propose the solution. is to download IronPdf 2021.9.3737 or greater from nuget and use the new IronPdf.ChromePdfRenderer Class which is functionally identical to desktop Chrome browser in 2021.

This fixed all of our rendering issues with HTML to PDF in C#, including kerning of the Arial typeface.

PM> Install-Package IronPdf -Version 2021.9.3737
Stephanie
  • 600
  • 13
  • 24
  • Another solution to fonts in HTML to PDF rendering is to use web fonts such as: https://fonts.google.com/specimen/Open+Sans There are many Arial like web fonts for free and IronPdf supports them. This removes need for the font to be present on the server / machine that runs your .NET code in production – Stephanie Oct 13 '21 at 02:40