Hello,
we are having an issue with current Aspose.Words version. We got a document which is missing information when saving to PDF or HtmlFixed. The issue only appears in OCI build.
var lic = new License();
lic.SetLicense(@"./workspace/Aspose.Total.NET.lic");
var externalFontSource = new Aspose.Words.Fonts.FolderFontSource("./fonts", true); // windows fonts
var systemFontSource =
new Aspose.Words.Fonts.FolderFontSource(Environment.GetFolderPath(Environment.SpecialFolder.Fonts),
true);
// Merge font sources
var fontSources =
new List<Aspose.Words.Fonts.FontSourceBase>(Aspose.Words.Fonts.FontSettings.DefaultInstance
.GetFontsSources())
{
externalFontSource,
systemFontSource
};
// Apply font sources
Aspose.Words.Fonts.FontSettings.DefaultInstance.SetFontsSources(fontSources.ToArray());
var options = new HtmlFixedSaveOptions();
options.MetafileRenderingOptions.RenderingMode = MetafileRenderingMode.Bitmap;
var doc = new Document(@"./workspace/in.docx");
doc.Save(@"./workspace/out.html", options);
The Dockerfile is
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["ConsoleApp5/ConsoleApp5.csproj", "ConsoleApp5/"]
RUN dotnet restore "ConsoleApp5/ConsoleApp5.csproj"
COPY . .
WORKDIR "/src/ConsoleApp5"
RUN dotnet build "ConsoleApp5.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ConsoleApp5.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
#Include contrib archive to install windows fonts. Must run before package update
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
#Installs "windows fonts"
RUN apt-get update && apt-get install -y ttf-mscorefonts-installer fontconfig
#SkiaSharp dependency of Aspose requires libfontconfig1. See Aspose documentation for this.
RUN apt-get update && apt-get install -y libfontconfig1
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp5.dll"]
In debugging we noticed that the issue is caused by setting
options.MetafileRenderingOptions.RenderingMode = MetafileRenderingMode.Bitmap;
If this is not set, the output is correct if the Windows Fonts directory is mounted into the container in ./fonts
.
However, we are using the RenderingMode as it solves another issue reported in another thread (see System.ArgumentException raised when saving a document with an object in HtmlFixed format).
The attached example contains
- in.docx → source file
- out.pdf / out.html → correct output version, saved as Pdf / HtmlFixed without the options
- out2.pdf / out2.html → defect output, saved using the options with
MetafileRenderingMode.Bitmap
- docker-compose.yml → containing the used mounts
example.zip (1.8 MB)
Docker Host system is a current Windows 10 version.
Thanks for your help.