reportviewercore icon indicating copy to clipboard operation
reportviewercore copied to clipboard

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

Open dinonovak opened this issue 3 years ago • 8 comments

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?

dinonovak avatar Sep 03 '22 11:09 dinonovak

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?

lkosson avatar Sep 05 '22 04:09 lkosson

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 } }

dinonovak avatar Sep 05 '22 06:09 dinonovak

What exception or RS error do you get?

lkosson avatar Sep 05 '22 06:09 lkosson

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 <ItemGroup Condition="'$(TargetFramework)' == 'net6.0'"> <PackageReference Include="ReportViewerCore.NETCore"> <Version>15.1.17</Version> </PackageReference> </ItemGroup>

dinonovak avatar Sep 05 '22 09:09 dinonovak

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

lkosson avatar Sep 05 '22 09:09 lkosson

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

lkosson avatar Sep 05 '22 11:09 lkosson

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.

dinonovak avatar Sep 06 '22 08:09 dinonovak

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.

lkosson avatar Sep 06 '22 09:09 lkosson