Saving word pages as image produces corrupted PNG files in Linux docker container


I noticed an issue that PNG files have an error when you save a word document as image under Linux docker container.

Test code:

var lic = new License();

var doc= new Document(@"./data/tmp/thumbnails/in.docx");
var options = new ImageSaveOptions(SaveFormat.Png);

var pageRange = new PageRange(0, 0);
options.PageSet = new PageSet(pageRange);
doc.Save(@"./data/tmp/thumbnails/out.png", options);


#See to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM AS base

FROM AS build
COPY ["ConsoleApp3/ConsoleApp3.csproj", "ConsoleApp3/"]
RUN dotnet restore "./ConsoleApp3/ConsoleApp3.csproj"
COPY . .
WORKDIR "/src/ConsoleApp3"
RUN dotnet build "./ConsoleApp3.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "./ConsoleApp3.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final

#Include contrib archive to install windows fonts. Must run before package update
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list

#Installs "windows fonts"
RUN apt-get update && apt-get install -y ttf-mscorefonts-installer fontconfig

#SkiaSharp dependency of Aspose requires libfontconfig1. See Aspose documentation for this. 
RUN apt-get update && apt-get install -y libfontconfig1

COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp3.dll"]

Project config (nuget packages):

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="Aspose.Words" Version="24.3.0" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.7" />


Test Files: (169.3 KB)

The produced PNG file under linux cannot be handled in some programming languages (delphi) due to an CRC error. The CRC error also can be validated through PNG file chunk inspector
image.png (87.9 KB)

As I am writing this, I noticed the PNG produced under windows also has a CRC error listed. The original document with which we first noticed the error was correct under windows and with CRC error under linux.
I cannot attach the full document but here are the PNG files from the other sample we had:
other (153.8 KB)

In both cases, the PNG produced by the docker container also is significantly larger (122 kb vs 65 kb and 108 kb vs 67 kb),

Thanks for your help.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26741

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Most likely this is a SkiaSharp problem, since Aspose.Words for .NET Standard and .NET Core versions uses it to deal with graphics. The difference in the produced image size is also caused by SkiaSharp, since different builds (native assets) are used in different environments.

The issues you have found earlier (filed as WORDSNET-26741) have been fixed in this Aspose.Words for .NET 24.6 update also available on NuGet.