lkosson / reportviewercore

Recompilation of Microsoft.ReportViewer for .NET Core 3.1+
408 stars 119 forks source link

Sending image as report parameter Base64 string - Linux, document cannot be opened in Word #105

Closed dinonovak closed 1 year ago

dinonovak commented 2 years ago

I am sending image as Base64 string as report parameter

String PictureBase64 = GetPicture(); ReportParameter rptParam = new ReportParameter("rpImageBase64", PictureBase64, true); report.SetParameters(rptParam);

Report is rendered correctly on windows and in PDF format. When rendering report as WORDOPENXML on Linux document is produced but it cannot be opened in word.

Any limits or specifics that need to be used for Linux case?

lkosson commented 2 years ago

It should work fine as long as you are not using .NET 6 (https://aka.ms/systemdrawingnonwindows). What error do you get when trying to render a report?

dinonovak commented 2 years ago

I am running it on .Net6. I need to run app in linux container.

Any idea if this in runtimeconfig.json would help? { "configProperties": { "System.Drawing.EnableUnixSupport": true } }

lkosson commented 2 years ago

What exception or RS error do you get?

dinonovak commented 2 years ago

I am using nugget packages, while running in docker container report is created, just there is no image in the report. I am using try/catch and not catching any errors.

report is rendered for linux using: report.Render("WORDOPENXML");

packages included

15.1.17
lkosson commented 2 years ago

In debugger output and/or RV warnings you should get a message describing what went wrong with the image.

lkosson commented 2 years ago

I have verified that RV on both .NET 3.1 and .NET 6 produces proper images when using docx renderer.

dinonovak commented 2 years ago

did a extensive research yestaerady, I was sending BMP as Base64 string, now I converted to PNG and all works ok. For some reports (probably due to large number of tables) render() produces DOCX file that cannot be opened in MS Word (Win & Mac), I am getting feedback from Word that document.xml has error on line1 (docx file can be unzipped and media folder contains all images in readable format). But as I am using syncfusion doc2pdf converter I somehow manages to open and convert file correctly. I tested on Win and Linux and same is happening on both platforms.

lkosson commented 2 years ago

I have tested using PNGs, with only a few images in the report. If you can reproduce the problem on Windows, you might as well check if it also happens in original RV. Perhaps it is a general deficiency in docx renderer.