Symbol font on ABCpdf
Asked Answered
N

3

6

I'm using the ABCpdf.net component to convert HTML to PDF. Some of the HTML uses the Symbol font to display certain characters. Unfortunately, we are consuming the HTML from a third-party, and it cannot be changed.

My development environment displays the font correctly, but my production environment will not. It acts as though the font is not installed, even though it is. If I render the same HTML in Internet Explorer on the production environment, it displays just fine.

I have tried embedding the font as an .eot and providing a @font-face style in the header. I have tried using TheDoc.AddFont('Symbol'). Any suggestions?

Product: ABCpdf .NET 7 x64

Production OS: Windows Server 2003 x64, IE8

Development OS: Win7 x64, IE8

Neel answered 22/9, 2011 at 20:38 Comment(0)
N
2

Although I said that the Doc.HtmlOptions was the answer, it turned out that it was something else entirely. The symbols did not show up because the font-weight was not normal (i.e., it was bold). There is no bold subset that contains these characters. IE is smart enough to ignore the bold part, but PDF is rather finicky. It cannot find the character, so it just shows nothing.

The real solution was to comb through the HTML and ensure that all symbols were surrounded by a span with font-weight: normal !important. It is perhaps a less elegant solution, but it is effective. The only symbol that still randomly refused to show up is the angle symbol (∠). For this, I replaced it with an image. I still can't figure out why it won't appear.

Neel answered 20/1, 2012 at 0:5 Comment(0)
N
6

The WebSuperGoo support team responded with the fix: setting font-related HtmlOptions. I set these options, and it fixed the issue. Yay!

If you want to embed the fonts used in a web page/HTML you need to use:
    Doc.HtmlOptions.FontEmbed = True
You may also need to set
    Doc.HtmlOptions.FontSubstitute = False
and possibly:
    Doc.HtmlOptions.FontProtection = False
before you use the Doc.AddImageUrl or Doc.AddImageHtml methods.

Edit: As I mention in the comment below, the option that did the trick was FontProtection = false.

Neel answered 23/9, 2011 at 2:48 Comment(3)
did you try them individually to see which line of code, or combination of lines made it work for you? I have tried the first line in the past without success - I might have been using it in the wrong place though.Potato
I did, actually. The problem is solved with just the FontProtection set to false.Neel
I had problems with my PDFs I generate from HTML and show in my iPad app. The problem was bullet points being rendered wrong. I changed the font type and set Doc.HtmlOptions.FontEmbed = True and that solved my issue.Epifaniaepifano
P
2

Try restarting the server.

I've had a similar issue with fonts on ABCPdf. Although the fonts were clearly installed, for some reason, ABDPdf didn't pick them up until the machine has been restarted.

There may be some non restart way of achieving the same thing, but that would entail understanding what the problem is! If it's easy, just try restarting.

Potato answered 22/9, 2011 at 20:48 Comment(1)
Yeah, the documentation says that the fonts are actually cached and won't be reloaded until the process is restarted. This is not my problem, unfortunately, but thank you! =]Neel
N
2

Although I said that the Doc.HtmlOptions was the answer, it turned out that it was something else entirely. The symbols did not show up because the font-weight was not normal (i.e., it was bold). There is no bold subset that contains these characters. IE is smart enough to ignore the bold part, but PDF is rather finicky. It cannot find the character, so it just shows nothing.

The real solution was to comb through the HTML and ensure that all symbols were surrounded by a span with font-weight: normal !important. It is perhaps a less elegant solution, but it is effective. The only symbol that still randomly refused to show up is the angle symbol (∠). For this, I replaced it with an image. I still can't figure out why it won't appear.

Neel answered 20/1, 2012 at 0:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.