x
ActiveReportsJS v5.2 is Here! Check out our newest update. ActiveReportsJS v5.2 is Here! ARJS 5.2 is Here!

CompatibilityModes.GDI in .NET 8.0 Rest Api project with AR v18

Posted by: mlk20 on 28 February 2025, 12:21 pm EST

  • Posted 28 February 2025, 12:21 pm EST

    Hi,

    I found the following statements:

    "

    The default value for the NET Framework is CompatibilityModes.GDI, while for other frameworks it is CompatibilityModes.CrossPlatform. The CompatibilityModes.GDI parameter is only compatible with the Windows operating system and is not suitable for ASP.NET Core. The CompatibilityModes.CrossPlatform setting is designed for cross-platform rendering.

    "

    "

    You may manually add the following code to set the CompatibilityMode to GDI in .NET Core in ActiveReports 16:

    SectionReport1 rpt = new SectionReport1();

    rpt.CompatibilityMode = GrapeCity.ActiveReports.Document.CompatibilityModes.GDI;

    Although this code will not help in the latest version, i.e., ActiveReports 17, as the GDI Compatibility Mode is not supported with .NET Core in the latest version.

    "

    My goal is to create a library which:

    a) Merges a SectionReport from the given RPX with the given DataSource. (Later the report is exported to PDF).

    b) Is compiled with .NET 8.0 in Rest Api projeject, using AR v18 and VS2022.

    c) Handles rich text correctly via RichTextBox control.

    d) When library is executed in Windows environment, then I expect to somehow use CompatibilityModes.GDI and RichTextBox merging provided RTF content (from DataSource).

    e) When library is executed in Linux environment, then I expect to somehow use CompatibilityModes.CrossPlatform and RichTextBox merging provided HTML content (from DataSource).

    Is that achievable (I am concerned about d) and e) point the most)?

    Thank you.

  • Posted 28 February 2025, 1:10 pm EST

    I also tried a simple code like:

    SectionReport ar = new SectionReport();

    ar.CompatibilityMode = CompatibilityModes.GDI;

    and in one of my test projects the compatibility mode is changed to GDI, while in other it stays to CompatiblityModes.CrossPlatform without throwing any exception/error etc… which seems to be weird. If there indeed are some reasons why the compatibility cannot be changed then there should be a way to be notified/aware of the reasons and not guess… as for now it seems to be not reliable to use it.

  • Posted 4 March 2025, 1:47 am EST

    Hi,

    As of now, when RTF is applied in RichTextBox in .NET Core application, it is rendered as blank.

    d) When library is executed in Windows environment, then I expect to somehow use CompatibilityModes.GDI and RichTextBox merging provided RTF content (from DataSource).

    e) When library is executed in Linux environment, then I expect to somehow use CompatibilityModes.CrossPlatform and RichTextBox merging provided HTML content (from DataSource).

    You can use the following code to get whether your application is Windows/Linux environment:

    string os = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows" :
                        RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "Linux" :
                        RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "macOS" : "Unknown";
    
            string framework = RuntimeInformation.FrameworkDescription;
    
    

    Depending on this you would have to run a separate process(or service) to run code in a .Net Framework Environment(assuming your application is running in .Net Core.

    For testing out the different behavior in .Net Core and .Net Framework with different Compatibility mode, please refer to the attached sample project.

    Regards,

    AkshayRTFnHTML.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels