Closed SoftCircuits closed 1 year ago
Please try either the "PDFsharp-MigraDoc-GDI" or the "PDFsharp-MigraDoc-WPF" NuGet packages published by PDFsharp-Team.
@TH-Soft Can you elaborate why? Do you know if PDFsharp supports .NET 6.0? I seem to be finding that it does not.
System.NotSupportedException: 'No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'
@SoftCircuits .Net Core 3.x/.NET5/6 doesn't know about any non-Unicode encoding - https://stackoverflow.com/a/37870346
Add reference to System.Text.Encoding.CodePages nuget and add the following line before using any non-Unicode encoding:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Does this solve the problem for you?
PDFsharp 6.0.0 now uses .NET 6.
Expected Behavior
I expected the simple Hello World example to run.
Actual Behavior
I don't seem to be able to create the font. On the line that creates an
XFont
, I got a compile error.I was able to reference this assembly and run the program. Then I got a run-time exception on the same line.
Steps to Reproduce the Behavior
Just tried to run the basic Hello World example. When it gets to the line that creates the font, I get the exception above.
I really don't understand the error or why, apparently, the author of the example code didn't have to deal with this issue. I just want to print two words on the page. What encoding does this refer to?
Note that I'm using .NET 6.0. I'm having trouble seeing which versions the library targets. Usually, under the Dependencies section on NuGet, it shows the target libraries. This one just says This package has no dependencies.
UPDATE:
And BTW, when I download the PDF associated with this example, I get a blank page.