PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Having issues upgrading from PDFSharp 1.5 to 6.0 https://forum.pdfsharp.net/viewtopic.php?f=2&t=4558 |
Page 1 of 1 |
Author: | RickSan [ Fri Mar 01, 2024 7:59 am ] |
Post subject: | Having issues upgrading from PDFSharp 1.5 to 6.0 |
Hi, I have upgraded from PDFSharp 1.5 to 6.0 and it has not been a smooth transition I am sorry to say. First of all I had some troubles with getting the assets to my solution. Download-assets.ps1 did not help at all. We are using the Font "Roboto" and Download-assets.ps1 didn't help with that. I had to download the font from google and manually put it in a folder where I then had to tell my new FontResolver-class to find it. I got it to work locally on my machine and deployed to our first test environment. Next problem: the fonts does not deploy automatically. I have to copy the fonts manually to each of our test-, qa-, education- and production environments. And we have 8 of those environments. I guess this is solvable in our CI/CD-pipeline somehow. Next problem: now the fonts are located on the server, then I get this error when reading the fonts and creating the fonts: System.NullReferenceException, Object reference not set to an instance of an object. at PdfSharp.Fonts.OpenType.OpenTypeFontface.CetOrCreateFrom(XFontSource fontSource) at PdfSharp.Drawing.XGlyphTypeface..ctor(String key, XFontFamily fontFamily, XFontSource fontSource, XStyleSimulations styleSimulations) 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) I don't know whats going on here. As I wrote, it works locally for me, but not when deployed to our first development-server. It fails on the line: XFont font = new XFont("Roboto", 80, XFontStyleEx.Bold); the line before that is: GlobalFontSettings.FontResolver = new RobotoFontResolver(); I am seriously thinking about downgrading to PDFSharp 1.5 again, where assets wheren't an issue. We are using .NET 6 btw. thanks for any help. Rickard |
Author: | TH-Soft [ Fri Mar 01, 2024 10:24 am ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
Hi! RickSan wrote: I have upgraded from PDFSharp 1.5 to 6.0 and it has not been a smooth transition I am sorry to say. Use the GDI build of PDFsharp 6.0 and font handling will be the same as with PDFsharp 1.5.You only have to use Download-assets.ps1 when you want to compile PDFsharp. Why not simply use the existing NuGet packages? |
Author: | RickSan [ Fri Mar 01, 2024 11:27 am ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: Hi! Use the GDI build of PDFsharp 6.0 and font handling will be the same as with PDFsharp 1.5. You only have to use Download-assets.ps1 when you want to compile PDFsharp. Why not simply use the existing NuGet packages? Okay, now we're on to something! Clearly I'm doing something wrong here. I am using the existing nuget packages, not compiling on my own. But the nuget package are not finding the assets (the font Roboto in my case) after upgrading. I upgraded the nuget package "PDFSharp" from 1.5 til 6.0.0. Is the solution to change nuget package to "PDFSharp-GDI" version 6.0.0? I thought that "PDFSharp-GDI" was made for use on windows clients (Windows Forms). In our case PDFSharp is run on the backend servers, not on clients. But I guess it could work anyway. I will try that out, see what happends. Thanks for the reply. |
Author: | TH-Soft [ Fri Mar 01, 2024 11:37 am ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
PDFsharp 1.5 uses GDI to load fonts from the Windows directory. So does PDFsharp-GDI 6.0. PDFsharp (Core) 6.0 relies on the FontResolver you supply. |
Author: | RickSan [ Fri Mar 01, 2024 2:03 pm ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: PDFsharp 1.5 uses GDI to load fonts from the Windows directory. So does PDFsharp-GDI 6.0. PDFsharp (Core) 6.0 relies on the FontResolver you supply. Thanks! Then I'll change nuget package to PDFsharp-GDI. Thank you for clearing this up for me. /Rickard |
Author: | RickSan [ Fri Mar 01, 2024 2:48 pm ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: PDFsharp 1.5 uses GDI to load fonts from the Windows directory. So does PDFsharp-GDI 6.0. PDFsharp (Core) 6.0 relies on the FontResolver you supply. Sorry, it did not work as intended Changing to PDFsharp-GDI requires me to change target framework to "net6.0-windows7.0". I can't do that. "Error NU1202 Package PDFsharp-GDI 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package PDFsharp-GDI 6.0.0 supports: net6.0-windows7.0 (.NETCoreApp,Version=v6.0)" So it seems like I have to downgrade to PDFSharp 1.5 then? I would like a version of PDFSharp that is compatible with .NET 6, and works like PDFSharp 1.5. It seems like that is to much to ask for. |
Author: | RickSan [ Mon Mar 04, 2024 1:17 pm ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: PDFsharp 1.5 uses GDI to load fonts from the Windows directory. So does PDFsharp-GDI 6.0. PDFsharp (Core) 6.0 relies on the FontResolver you supply. Since I couldn't migrate to PDFSharp-GDI, I guess I have to choose between downgrading to 1.5 again, or trying to find out why I am getting System.NullReferenceException inside PdfSharp.Fonts.OpenType.OpenTypeFontface.CetOrCreateFrom().. And since I have no clue to where to start on that, downgrading seems to be the easiest option. Even though I really don't want to. |
Author: | TH-Soft [ Mon Mar 04, 2024 2:17 pm ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
RickSan wrote: And since I have no clue to where to start on that, downgrading seems to be the easiest option. PDFsharp 1.5 is from 2019 and targets .NET 2.0.Reporting issues against PDFsharp 6.x: https://docs.pdfsharp.net/General/IssueReporting.html |
Author: | RickSan [ Mon Mar 04, 2024 11:29 pm ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: RickSan wrote: And since I have no clue to where to start on that, downgrading seems to be the easiest option. PDFsharp 1.5 is from 2019 and targets .NET 2.0.Reporting issues against PDFsharp 6.x: https://docs.pdfsharp.net/General/IssueReporting.html Yes, I know. It's not ideal. Now I tried the preview of PDFSharp-GDI 6.1.0-preview-1, and that does target .net6.0 it seems like. Maybe I'll switch to that. Any idea when a stable version of 6.1.0 is coming? Thanks again for all help. |
Author: | TH-Soft [ Tue Mar 05, 2024 8:44 am ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
RickSan wrote: view of PDFSharp-GDI 6.1.0-preview-1, and that does target .net6.0 it seems like. It targets net6.0-windows7.0.RickSan wrote: Any idea when a stable version of 6.1.0 is coming? The next preview should come in a few days, but no ETA yet for a stable version.
|
Author: | RickSan [ Tue Mar 05, 2024 8:48 am ] |
Post subject: | Re: Having issues upgrading from PDFSharp 1.5 to 6.0 |
TH-Soft wrote: RickSan wrote: view of PDFSharp-GDI 6.1.0-preview-1, and that does target .net6.0 it seems like. It targets net6.0-windows7.0.Yeah, I saw that. But it also targets .NET Framework 4.7.2 so I guess that's why it works for me. RickSan wrote: Any idea when a stable version of 6.1.0 is coming? The next preview should come in a few days, but no ETA yet for a stable version.[/quote]OK, thanks. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |