PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
NewFontResolver is missing in 6.1.0 http://forum.pdfsharp.de/viewtopic.php?f=2&t=4601 |
Page 1 of 1 |
Author: | andrus [ Wed May 29, 2024 12:46 pm ] |
Post subject: | NewFontResolver is missing in 6.1.0 |
After installing PDFsharp-MigraDoc 6.1.0 from NuGet code Code: static ReportTemplateBase() { GlobalFontSettings.FontResolver = new NewFontResolver(); } Throws error Quote: The type or namespace name 'NewFontResolver' could not be found (are you missing a using directive or an assembly reference?) How to fix it? Times New Roman and Arial .ttf files are copied to Debian to /usr/share/fonts/winfonts directory. How to use fonts in Debian from this directory for pdf creation. Font files can copied to other directories if this helps. |
Author: | TH-Soft [ Wed May 29, 2024 12:58 pm ] |
Post subject: | Re: NewFontResolver is missing in 6.1.0 |
See documentation: https://docs.pdfsharp.net/General/Histo ... ntresolver Quote: Note that NewFontResolver was renamed to SnippetsFontResolver with version 6.1.0 Preview 1. Note that SnippetsFontResolver is no longer available as of version 6.1.0 Preview 3. Functionality from NewFontResolver was moved to PlatformFontResolver, so Arial and Times New Roman should work under Linux without setting a font resolver if they worked with the NewFontResolver. See also: https://docs.pdfsharp.net/PDFsharp/Topi ... About.html |
Author: | andrus [ Wed May 29, 2024 1:28 pm ] |
Post subject: | Re: NewFontResolver is missing in 6.1.0 |
I removed this code and run application from Visual Studio IDE in Windows 11. It throws error Quote: System.InvalidOperationException HResult=0x80131509 Message=No appropriate font found for family name 'Calibri'. Implement IFontResolver and assign to 'GlobalFontSettings.FontResolver' to use fonts. See https://docs.pdfsharp.net/link/font-resolving.html Source=PdfSharp StackTrace: at PdfSharp.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharp.Drawing.XFont.Initialize() at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style, XPdfFontOptions pdfOptions) at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style) at MigraDoc.DocumentObjectModel.TextMeasurement.Realize() in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 154 at MigraDoc.DocumentObjectModel.TextMeasurement.MeasureString(String text, UnitType unitType) in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 74 at MigraDoc.DocumentObjectModel.TextMeasurement.MeasureString(String text) in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 114 ... Windows has Calibri font installed. Using NewFontresolver() it worked in Windows and Linux. How to fix this? If it is not possible to use Calibri, some other font can used so that pdf is created. How to force PDFSharp to silently use Calibri or some other font without throwing error? |
Author: | TH-Soft [ Wed May 29, 2024 1:41 pm ] |
Post subject: | Re: NewFontResolver is missing in 6.1.0 |
andrus wrote: If it is not possible to use Calibri, some other font can used so that pdf is created. Out of the box, you can use fonts like Arial, Verdana, Times New Roman, and some others. See code here: https://github.com/empira/PDFsharp/blob ... esolver.cs Calibri is not on that list. Either grab the code from NewFontResolver from version 6.0 or write a FontResolver that supports Calibri or use other fonts like Verdana and Arial. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |