We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word to PDF Conversion Font Family is not retained in docker linux container

I am running .NET Core 2.1 application inside a Linux Docker Container and Converting Word to PDF. While converting the Font Family isn’t retained and is getting changed.

FROM mcr.microsoft.com/dotnet/core/runtime:2.1-stretch-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["./.", "PdfPOC/"]
RUN dotnet restore "PdfPOC/PdfPOC.csproj"
COPY . .
WORKDIR "/src/PdfPOC"
RUN dotnet build "PdfPOC.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "PdfPOC.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
#RUN apt-get install -y ttf-mscorefonts-installer
RUN apt-get update && apt-get install -y libfontconfig1 apt-utils libgdiplus libc6-dev
RUN apt-get install -y libfreetype6
ENTRYPOINT ["dotnet", "PdfPOC.dll"]

My Code is -

            Aspose.Words.License lic = new Aspose.Words.License();
            lic.SetLicense("Aspose.Words.lic");
     
            Aspose.Words.Document word2 = new Aspose.Words.Document(Path.Combine(path, "myword.docx"));
           
            word2.Save(Path.Combine(path, "mypdf.pdf"), Aspose.Words.SaveFormat.Pdf);

The word has a variant of sans-serif font but the converted pdf file has serif font. Also if the word has multiple fonts how to make sure all fonts are retained ?

@adithya_sai

Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you are converting documents to PDF. Please refer to the following articles:

How Aspose.Words Uses True Type Fonts
How to Receive Notification of Missing Fonts and Font Substitution during Rendering