ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.08k stars 237 forks source link

MigraDocCore Pdf with unexpected font #313

Closed wbison closed 1 year ago

wbison commented 1 year ago

A Pdf rendered using MigraDocCore.Rendering 1.3.43 in a .Net Core 7 application on Azure (Windows) is using an unexpected comicsans- like font.

Running the same code locally on a Mac results in a Pdf with a normal font but italic.

This sample in the docs includes a FontResolver line but I'm unsure what that does.

GlobalFontSettings.FontResolver = new FontResolver();

Adding the line as-is has no effect. Should I implement a customer resolver? How?

This sample includes a special PdfDocumentRenderer

PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false,
PdfFontEmbedding.Always);

but the lib I use does not have a constructor with a second embedding option.

Any suggestions?

wbison commented 1 year ago

Was caused by specifying wrong font - duh :-(

Thomas-HG commented 1 year ago

Hi @wbison ,

I'm having the same issue as you on MacOS: I don't change any font parameters but the font in PDF is rendered in Italic...

How did you solve your issue ?

Thanks !

wbison commented 1 year ago

I had specified a non-existent font; this was not a problem in the original configuration but resulted in weird renderings on .Net 7/Windows. So the solution is to make sure you use a font that exist in the environment your app runs in.