Word to PDF and image conversion, not supporting Chinese

Docker is running, and with these installed, there are many fonts available.

But not yet, he won't get involved in the following events,



WordDocument doc = new WordDocument();
doc.FontSettings.SubstituteFont += FontSettings_SubstituteFont;


```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/*

RUN apt-get install -y ttf-mscorefonts-installer

```


7 Replies

DA Dharanitharan Ayyasamy Syncfusion Team July 9, 2024 02:54 PM UTC

Hi,

We have tried to replicate the reported Chinese characters not supported query using a docker sample application by converting the Word document to PDF. But it is working fine from our end. Kindly find the sample attachment which we are used to replicate the reported query. We suspect that the Chinese characters are not supported problem may be related to the input document. If you are still facing the issue, kindly share us the issue reproducible modified sample application along with the input word documents from your side, which will be helpful to reproduce the exact issue at our end. Thereby we will analyze further and provide you the appropriate solution at the earliest.

Regards,
Dharanitharan A.


Attachment: WordToPDFDockerSample_5eadaa62.zip


XZ xu zhi bin replied to Dharanitharan Ayyasamy July 10, 2024 01:06 AM UTC

I have sent it to you,


Is there any other way to force font settings?

Unable to send file.



Image_2775_1720573521995



XZ xu zhi bin July 10, 2024 01:11 AM UTC

I tested your Word but it still doesn't work, indicating that it's not a file issue. Maybe there's a difference here.





XZ xu zhi bin replied to Dharanitharan Ayyasamy July 10, 2024 01:52 AM UTC

Please help me test the layer I built myself

bbhxwl/net8:latest 

Image_3105_1720576313147


Dockerfile





FROM bbhxwl/net8:latest AS base

EXPOSE 5000

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /src

COPY ["bbhxwlApi/bbhxwlApi.csproj", "bbhxwlApi/"]

RUN dotnet restore "bbhxwlApi/bbhxwlApi.csproj"

COPY . .

WORKDIR "/src/bbhxwlApi"

RUN dotnet build "bbhxwlApi.csproj" -c Release -o /app/build


FROM build AS publish

RUN dotnet publish "bbhxwlApi.csproj" -c Release -o /app/publish


FROM base AS final

WORKDIR /app

ENV LANG="zh_CN.UTF-8"

RUN ls /usr/share/fonts/truetype/msttcorefonts

RUN cp /usr/lib/x86_64-linux-gnu/libdl.so.2 /app/libdl.so

COPY --from=publish /app/publish .

ENV ASPNETCORE_URLS=http://0.0.0.0:5000

ENTRYPOINT ["dotnet", "bbhxwlApi.dll"]




DA Dharanitharan Ayyasamy Syncfusion Team July 10, 2024 11:02 AM UTC

xu, from the given details, we suspect that you have missed to install the required dependent NuGet packages to perform Word to PDF conversion in your application in Docker environment. So, the reported Chinese characters not supported issue occurs at your end.

To resolve the reported issue, kindly uninstall the installed packages in your application.

Version

NuGet packages to install

From v23.1.40

SkiaSharp.NativeAssets.Linux v2.88.6
HarfBuzzSharp.NativeAssets.Linux v7.3.0


In addition to the
Syncfusion.DocIORenderer.Net.Core NuGet package, please install the above mentioned NuGet packages in your application and let us know whether the reported issue gets resolved.

If you are still facing the reported issue, kindly share us the below details,
which will be helpful to reproduce the exact issue at our end,
1. List of NuGet packages installed in your application
2. Syncfusion Product version
3. Input Word document

Thereby we will analyze this further and provide you with the appropriate solution at the earliest.



XZ xu zhi bin replied to Dharanitharan Ayyasamy July 10, 2024 12:59 PM UTC

Originally, I installed the second one, but it was resolved after installing the first one. I don't know what the difference is.



Image_1601_1720616354993



DA Dharanitharan Ayyasamy Syncfusion Team July 11, 2024 08:28 AM UTC

xu, happy to hear that your problem was resolved using our suggestions. While converting the Word document to PDF with the help of “SkiaSharp.NativeAssets.Linux.NoDependencies” will leads to text missing issue, because this library does not contain font configuration in it. Therefore, we are unable to measure or draw text using this library, but we can draw the necessary shapes. On the other hand, “SkiaSharp.NativeAssets.Linux” library allows us to measure and draw the necessary text as well as draw shapes. Therefore, the required Chinese characters were preserved properly in the converted PDF file by referring the “SkiaSharp.NativeAssets.Linux” NuGet.

For more information, kindly refer : Readme - SkiaSharp.NativeAssets.Linux.NoDependencies


Loader.
Up arrow icon