Apose.Words Linux RedHat

Hi, good morning. I’m contacting because I’m currently working in a project where we need convert a word document into a pdf document and the images are not rendered.
We are using .Net running inside a Linux container but due to our company policies we need to use RedHat Linux as base docker image.
The instructions published in the Aspose official documentation “How to Run Aspose.Words in Docker” doesn’t fit for us because it is based on an Ubuntu image and for RedHat we can’t use the “RUN apt-get update && apt-get install -y libfontconfig1” command, but libfontconfig1 is not even in the RedHat repository as well.

We have tried the follwing:

  1. Using the SkiaSharp.NativeAssets.Linux NuGet package.
  2. Using the SkiaSharp.NativeAssets.Linux.NoDependencies NuGet package.
  3. Using the Aspose.Drawing.

Can you please help with this topic?
My company is having the license for the Aspose 25.2 version.
Here you have the docker file code we have been trying:

FROM {company-repository}/dotnet:8.0

WORKDIR /app

ARG bin_path

COPY $bin_path /app/
COPY DocGenService/fonts/ /usr/share/fonts/truetype/msttcorefonts
COPY DocGenService/libgdiplus-6.0.4-3.el8.x86_64.rpm /app/

USER root
RUN microdnf install -y cairo fontconfig libpng libjpeg giflib libexif libtiff
RUN fc-cache -fv
RUN rpm -i /app/libgdiplus-6.0.4-3.el8.x86_64.rpm
RUN rm /app/libgdiplus-6.0.4-3.el8.x86_64.rpm

USER appUser

ENTRYPOINT ["dotnet", "DocGenService.Api.dll"]

@danirey

Good morning! It seems you’re experiencing issues with rendering images when converting a Word document to PDF using Aspose.Words in a RedHat Linux environment. The absence of libfontconfig1 in your base Docker image may contribute to these rendering problems.

Here are some steps to troubleshoot and potentially resolve the issue:

  1. Ensure All Required Libraries Are Installed: Verify that all necessary libraries for image processing are installed. In your Dockerfile, you are already including cairo, fontconfig, libpng, libjpeg, giflib, libexif, and libtiff. Double-check that these libraries are correctly installed and accessible in your environment.

  2. Use SkiaSharp: Since you mentioned using the SkiaSharp.NativeAssets.Linux and SkiaSharp.NativeAssets.Linux.NoDependencies packages, ensure you are using a version compatible with your .NET version. SkiaSharp is crucial for rendering graphics in a Linux environment.

  3. Check Font Availability: After copying fonts to /usr/share/fonts/truetype/msttcorefonts, confirm that the fonts are recognized by the system. You can run fc-list in your container to verify that the fonts are listed.

  4. Update Aspose.Words: If possible, consider updating to a newer version of Aspose.Words. You mentioned using version 25.2; upgrading to a more recent version may resolve issues related to image rendering.

  5. Test with a Simple Document: Create a simple Word document with minimal content and a single image to determine if the issue persists. This can help isolate whether the problem lies with the specific document or the conversion process itself.

  6. Log Errors: Implement logging in your application to capture any exceptions or errors during the conversion process. This can provide valuable insights into what might be going wrong.

Here’s a minimal code snippet to ensure you are correctly loading and saving the document:

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Total.lic");

Aspose.Words.Document doc = new Aspose.Words.Document(@"Test.docx");
doc.UpdatePageLayout();
doc.Save(@"Test.pdf", Aspose.Words.SaveFormat.Pdf);

If the issue persists after trying these steps, consider reaching out to Aspose support with detailed logs and the specific document you are working with.

Let me know if you need further assistance!

@danirey Which version of Aspose.Words and SkiaSharp.NativeAssets.Linux do you use in your project? The problem might occur because the versions are not compatible.

Hi @alexey.noskov, thanks for the quick response.
We were trying with the Aspose.Words 25.2.0 and SkiaSharp.NativeAssets.Linux 3.119.1 “but” I’m in touch with the licenses department of my company and they are going to share the most recent license file and then I’ll be able to use the 25.10.0 version.
What versions combination should I use?

@danirey Aspose.Words 25.2 version was tested with SkiaSharp 3.116.1. So please try downgrading SkiaSharp.NativeAssets to 3.116.1 version.

I’m going to try but I’ve just received the Aspose.Net 25.10 license. What SkiaSharp package version should I use with the Aspose.Net 25.10?

@danirey Aspose.Words 25.10 version uses SkiaSharp 3.119.0.

Hi @alexey.noskov,

I tried with the Aspose.Words 25.10 version and SkiaSharp 3.119.0 combination and it worked.
Thanks very much for the support! It was quick, efficient and precise.

Regards,

1 Like