Frequently asked questions about using DocIO in Linux

13 Jun 20246 minutes to read

The frequently asked questions about using DocIO in Linux environment are listed below.

How to copy necessary fonts to Linux containers?

The fonts present in the location (in Docker container) “/usr/local/share/fonts/” is used for conversion. By default, there will be limited number of fonts available in the container.

You should copy necessary fonts to this location “/usr/local/share/fonts/” before conversion.

Use the following code example to copy fonts to containers.

COPY ["ProjectName/FontsFolder/*.*", "/usr/local/share/fonts/"]

You can download a complete working sample from GitHub.

How to copy necessary Microsoft compatible fonts to Linux?

The fonts present in the location (in Linux) “/usr/share/fonts/” is used for conversion. By default, there will be limited number of fonts available in the Linux.

Use the following code example to install the Microsoft compatible fonts to Linux.

sudo apt-get install ttf-mscorefonts-installer

After the installation, the necessary Microsoft compatible fonts will be available in this location “/usr/share/fonts/truetype/msttcorefonts”, which will be considered for conversion.

NOTE

To use Microsoft fonts in your environment, kindly get the license clearance from Microsoft on your side.

How to install necessary fonts in Linux containers?

In Word to PDF conversion, Essential DocIO uses the fonts which are installed in the corresponding production machine to measure and draw the text. If the font is not available in the production environment, then the alternate font will be used to measure and draw text based on the environment. And so, it is mandatory to install all the fonts used in the Word document in machine to achieve proper preservation.

Use the following code example to install fonts in containers.

RUN apt-get update -y && apt-get install libfontconfig -y
RUN echo "deb http://httpredir.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list \ 
    && echo "deb http://httpredir.debian.org/debian buster-updates main contrib non- free" >> /etc/apt/sources.list \
    && echo "deb http://security.debian.org/ buster/updates main contrib non-free" >> /etc/apt/sources.list \
    && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
    && apt-get update \
    && apt-get install -y \
        fonts-arphic-ukai \
        fonts-arphic-uming \
        fonts-ipafont-mincho \
        fonts-ipafont-gothic \
        fonts-unfonts-core \
        ttf-wqy-zenhei \
        ttf-mscorefonts-installer \
    && apt-get clean \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/*

How to set culture/locale in Docker containers (Windows and Linux containers)?

By default, Culture/Locale that is specified in the container image will be used in Docker containers.

If you want to change or set Culture/Locale in the Docker container, set the required Culture/Locale in Docker file.

TIPS

We recommend you check whether the required Culture/Locale is set to the Docker containers since some Docker container may not have Culture/Locale.

The following code example will set en_US locale to the container by setting Language to en_US.

ENV LANG="en_US.UTF-8"

How to resolve LibSkiaSharp not found exception?

  • In Docker container, ensure whether the libfontconfig package properly installed by adding the following line in your Docker file.
RUN apt-get update -y && apt-get install libfontconfig -y
  • In production environment (hosted server machine), ensure whether the Visual C++ Redistributable is properly installed.

Download and install Visual C++, if not installed.

How to perform Word to PDF in Linux prior to v18.4 release?

In Linux OS, you can perform the Word to PDF conversion using .NET Core (Targeting .netcoreapp) application. You can refer Word to PDF conversion NuGet packages to know about the packages required to deploy .NET Core (Targeting .netcoreapp) application with Word to PDF conversion capabilities.

In addition to the previous NuGet packages, SkiaSharp.Linux helper NuGet package is required that can be generated by the following steps:

  1. Download libSkiaSharp.so here.
  2. Create a folder and name it as SkiaSharp.Linux and place the downloaded file in the folder structure “SkiaSharp.Linux\runtimes\linux-x64\native”
  3. Create a nuspec file with name SkiaSharp.Linux.nuspec using the following metadata information and place it inside SkiaSharp.Linux folder. The nuspec file can be customized.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
    <metadata>
        <id>SkiaSharp.Linux</id>
        <version>1.59.3</version>
        <title>SkiaSharp for Linux</title>
        <authors>Syncfusion Inc.</authors>
        <owners>Syncfusion Inc.</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>SkiaSharp for Linux is a supporting package for Linux platforms.</description>
        <tags>linux,cross-platform,skiasharp,net-standard,net-core,word-to-pdf</tags>
        <dependencies>
            <group targetFramework=".NETStandard1.4">
                <dependency id="SkiaSharp" version="1.59.3" />
            </group>
        </dependencies>
    </metadata>
</package>
  1. Make sure that the nuget.exe file is present along with SkiaSharp.Linux folder (in the parent folder of SkiaSharp.Linux folder). If not, download it from here.
  2. Open a command prompt and navigate to SkiaSharp.Linux folder.
  3. Execute the following command.
nuget pack SkiaSharp.Linux\SkiaSharp.Linux.nuspec -outputdirectory "C:\NuGet" 

The output directory can be customized as per your need.

Now, SkiaSharp.Linux NuGet will be generated in the mentioned output directory and add the generated NuGet as additional reference. You can also find the SkiaSharp.Linux NuGet package created by us from here.

What are the NuGet packages to be installed to perform Word to PDF conversion in Linux OS?

In Linux OS, you can perform Word to PDF conversion using .NET Core (Targeting .netcoreapp) application. You can refer Word to PDF conversion NuGet packages to know about the packages required to deploy .NET Core (Targeting .netcoreapp) applications with Word to PDF conversion capabilities.

In addition to the previous NuGet packages, the following NuGet packages need to be installed in your application.

Version NuGet packages to install
From v23.1.40

SkiaSharp.NativeAssets.Linux v2.88.6


HarfBuzzSharp.NativeAssets.Linux v7.3.0

From v20.3.0.56

SkiaSharp.NativeAssets.Linux v2.88.2


HarfBuzzSharp.NativeAssets.Linux v2.8.2.2

From v20.1.0.x

SkiaSharp.NativeAssets.Linux v2.88.0-preview.209


HarfBuzzSharp.NativeAssets.Linux v2.8.2-preview.209

From v19.4.0.x

SkiaSharp.NativeAssets.Linux v2.80.2 NuGet


HarfBuzzSharp.NativeAssets.Linux v2.6.1.7 NuGet

From v18.4.0.x to 19.4.0.x

SkiaSharp.NativeAssets.Linux v2.80.2 NuGet


Before v18.4.0.x Install SkiaSharp.Linux NuGet package for .Net Core application in Linux OS. you can find the SkiaSharp.Linux NuGet package created by us from

here

.
For more information, Please refer

here

.

What are the NuGet packages to be installed to perform Word to Image conversion in Linux OS?

In Linux OS, you can perform Word to Image conversion using .NET Core (Targeting .netcoreapp) application. You can refer Word to Image conversion NuGet packages to know about the packages required to deploy .NET Core (Targeting .netcoreapp) applications with Word to Image conversion capabilities.

In addition to the previous NuGet packages, the following NuGet package need to be installed in your application.

Version NuGet packages to install
From v23.1.40

SkiaSharp.NativeAssets.Linux v2.88.6


HarfBuzzSharp.NativeAssets.Linux v7.3.0

From v20.3.0.56

SkiaSharp.NativeAssets.Linux v2.88.2


HarfBuzzSharp.NativeAssets.Linux v2.8.2.2

From v20.2

SkiaSharp.NativeAssets.Linux v2.88.0-preview.209


HarfBuzzSharp.NativeAssets.Linux v2.8.2-preview.209