PDFsharp on Azure with Custom Fonts

谁说胖子不能爱 提交于 2019-12-09 03:15:31

The font handling of PDFsharp 1.50 was overhauled - also with Azure and Medium Trust in mind. I'd recommend using PDFsharp 1.50 (latest version is beta 3) or later for Azure. I think the WPF build will be appropriate.
The new IFontResolver gives you better control of font handling.
The samples package for PDFsharp 1.50 includes a sample. Alternatively you can use EZFontResolver from a third party.

With respect to PDFsharp 1.32: there are different builds that expose different overloads for AddFont. I'd also recommend the WPF build for Azure.
Font handling is platform-specific (GDI+ or WPF). It can be difficult to get the font names "correct" to have the platform use the custom font.
PDFsharp 1.32 includes a working WPF sample that uses a font from a resource. You can use this sample to get started.

GDI+ is not an option for Azure web sites as far as I know. So WPF is the way to go. I would use version 1.50 with the new IFontResolver interface. With the EZFontResolver implementation it is easy to use. There is a sample for PDFsharp 1.50 that shows an implementation of IFontResolver that can be used as a template if you want to do it without EZFontResolver.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!