Not getting images in docx to html conversion

Hello,

Currently, we are trying to convert word(docx/doc) file to html with the help of nuget package of Aspose.Words with version number 24.7.0.

Link: https://www.nuget.org/packages/Aspose.Words/24.7.0

Below code is used with HtmlFixedSaveOptions class.

HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions();
htmlFixedSaveOptions.PageMargins = 0;
htmlFixedSaveOptions.ExportEmbeddedCss = true;
htmlFixedSaveOptions.ExportEmbeddedFonts = true;
htmlFixedSaveOptions.ExportEmbeddedImages = true;
htmlFixedSaveOptions.ExportEmbeddedSvg = true;
htmlFixedSaveOptions.PrettyFormat = true;

Now, with this setup of code it is working fine in local system while running the application from visual studio. But post deployment through Kubernetes when the API is called then image tags are missing after converting docx to html.

In local system when an API is called for this conversion then it is able to produce the img html tag properly but doesn’t work post deployment.
Is there any other settings needed to be defined with HtmlFixedSaveOptions object?

@ankitchhelavda Most likely your application is deployed to Linux server, but the development environment is Windows.
Aspose.Words for .NET Standard uses SkiaSharp to deal with graphics, to make it work on Linux you have to add reference either to SkiaSharp.NativeAssets.Linux or to SkiaSharp.NativeAssets.Linux.NoDependencies

If you add reference to SkiaSharp.NativeAssets.Linux, you should also install libfontconfig1 in your system. SkiaSharp.NativeAssets.Linux depends on this library. You can use the following command to install it:

apt-get update && apt-get install -y libfontconfig1

If you do not have rights to install packages, or other reasons not to install libfontconfig1, you can simply use SkiaSharp.NativeAssets.Linux.NoDependencies , which does not require installation of libfontconfig1.

@alexey.noskov thanks for your response.
Yes application is deployed to Linux server. And I can install any Nuget package which you have mentioned.

From both the Nuget packages which is the best option to use?
What is your recommendation?

@ankitchhelavda I would recommend SkiaSharp.NativeAssets.Linux 2.88.8 and libfontconfig1 package.

@alexey.noskov Alright thanks.

So with SkiaSharp.NativeAssets.Linux you asked to install libfontconfig1 on the system. Are you suggesting to install this libfontconfig1 on the Linux server where application is deployed?

If that is the case then I don’t have access to install this on the server.

@ankitchhelavda Yes, libfontconfig1 is required by SkiaSharp.NativeAssets.Linux NuGet package.

@alexey.noskov Then I don’t have access to install libfontconfig1 on Linux server.

I will have to go with SkiaSharp.NativeAssets.Linux.NoDependencies Nuget package which I directly install through Visual Studio in my application.

I hope SkiaSharp.NativeAssets.Linux.NoDependencies will work the same way as SkiaSharp.NativeAssets.Linux does.

@ankitchhelavda Yes, it will be enough to use SkiaSharp.NativeAssets.Linux.NoDependencies.

Thanks @alexey.noskov , it worked fine.

1 Like