Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Apr 29, 2022 7:25 am

Dear Support,

we are in the process of updating our WPF Application from .Net Framework 4.8 to .Net6.
In our reporting we make use of emf-files.

Unfortunately we noticed, that emf-files do not seem to be supported in .Net6.
Running the following Test in a .Net 4.8 Framework test works, whereas it fails with ArgumentException: Not support metafile in .Net 6

Code: Select all
[Test]
public void TestPdfImageFromFile{
  FileInfo fileInfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
  PdfImage.FromFile(Path.Combine(fileInfo.DirectoryName, "partial_variances.emf"));
}


Can you confirm, that this behaviour is by design for .Net 6?
Can you point me to an alternative wich allows us to continue using vector based images in Spire generated PDFs in .Net 6?
Can you predict when above code will work for .Net 6 projects?

Thanks in advance, Andreas

external.ambluemlein
 
Posts: 2
Joined: Fri Apr 29, 2022 7:12 am

Fri Apr 29, 2022 8:06 am

Hello,

Thank you for your inquiry.
Please note that only System.Drawing supports vector graphics in Windows systems, but .NET6 is cross-platform, it does not support loading the Metafile type imageor converting the PDF file to the Metafile type image. Therefore, the code you mentioned above will not be supported on the .NETCore platform. Hope you can understand.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Fri Apr 29, 2022 9:05 am

Dear Annika,

Thank you very much for your fast response. I have a hard time understanding it though.
It sounded as if it was not possible at all, whereas worst case i thought it is a feature request.

Yes, .Net 6 enables cross platform development, but it also allows the execution of platform specific code.
In my .Net 6 Core App (Unit test project), i can create a Metafile

Code: Select all
var image = new System.Drawing.Imaging.Metafile(path);


... explicitly or implicitly by ...

Code: Select all
Image.FromFile(path);


The latter produces the warning ca1416 as the code will only be able to run on the windows platform.
But that´s expected and i only intend to execute it on this platform which i can kind of document by adding the attribute [SupportedOSPlatform("windows")] to the surrounding method.

I think your library could include platform specific APIs platform-conditionally compiled and/or properly marked with the [SupportedOSPlatform("windows")] attribute.
From my perspective this would be much more desireable then (as it feels for us) breaking changes in the release history.

It is a complex topic and i could be missing something, please let me know if so.

Best regards, Andreas

external.ambluemlein
 
Posts: 2
Joined: Fri Apr 29, 2022 7:12 am

Fri Apr 29, 2022 9:27 am

Hello,

Thanks for your feedback.
I shared your feedback with our developers, and they will investigate whether it is possible to implement Spire.PDF support for loading Metafile type images on Windows systems. Once there is any update, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF