-1

I'm rendering a PDF using MigraDocCore, when I run my app locally these symbols render correctly:

Symbols rendering correctly when running locally

But when I run it in Azure App Service the symbols are missing:

Symbols rendering incorrectly in Azure

My default Style is defined as

Style style = Document.Styles["Normal"];
style.Font.Name = "Arial";
style.Font.Color = Colors.Black;
style.ParagraphFormat.SpaceAfter = Unit.FromMillimeter(5);

Why are these symbols not rendering correctly in Azure and how can I fix it?

---- Edit:
I've just noticed as I post this that the one of the m³ is rendering correctly in Azure, while others aren't.

Grab showing one ³ symbol working in Azure while others don't

The difference here is that the one's not working are hard coded strings while the one that does work is going through the Localizer.

e.g.

var tf = section.AddTextFrame();

// This works
var str = L("m³");
var para = tf.AddParagraph(str);

// This doesn't work
var para = tf.AddParagraph("m³");

If I check the character code of the hard coded ³ and the one in my localization json they're both char 179.

The only difference I can see here is the json file is UTF-8 without the BOM, while the .cs file is ~~UTF-8 with a BOM~~ Western European. (This is probably going to be the issue).

I've saved the .cs file as UTF-8 without the BOM and will report back...

Greg B
  • 14,597
  • 18
  • 87
  • 141
  • use the following steps 1. Install the WPF build of 'PDFsharp' 1.50 beta 2 from NuGet 2. Use a Font Resolver to select the font Using private fonts with 'PDFsharp' 1.50 beta 2 or 'MigraDoc' 3. Add the 'unicode' font as an embedded resource in the project. Refer: (https://stackoverflow.com/a/32980927/15997690) – Delliganesh Sevanesan Aug 13 '21 at 12:10
  • Files without BOM may be interpreted in different ways depending on the regional settings of the computer. There was a time when PDFsharp/MigraDoc did not compile in China because some *.cs files did not have the BOM. Did you solve your problem? – I liked the old Stack Overflow Aug 25 '21 at 06:02

1 Answers1

0

To solve this problem, need to use the below steps:

  1. Install the WPF build of PDFsharp 1.50 beta 2 from NuGet

  2. Use a Font Resolver to select the font Using private fonts with PDFsharp 1.50 beta 2 or MigraDoc

  3. Add the unicode font as an embedded resource in the project.

The similar type of font issue in PDFSharp refer here

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15