Works fine locally. Issue happens in docker container running on Alpine Linux.
GroupDocs.Conversion: v22.12
.NET version: .NET 7.0
Error Message:
GroupDocs.Conversion.Exceptions.GroupDocsConversionException: Object reference not set to an instance of an object. at d.() at GroupDocs.Conversion.Converter.() at GroupDocs.Conversion.Converter.Convert(SaveDocumentStream document, ConvertedDocumentStream documentCompleted, ConvertOptions convertOptions)
Sample Code:result.Content is a base64 string
using (var inputStream = new MemoryStream(result.Content))
{
using (var outputStream = new MemoryStream())
{
using (Converter converter = new Converter(() => inputStream))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert(() => outputStream, (convertedStream, sourceName) =>
{
result.Content = outputStream.ToArray();
}, options);
}
result.MimeType = "application/pdf";
}
}
Do we have any updates / resolution for smauro’s above issue?
We are in the same team and this is becoming urgent for us and our customer.
We would like to make sure this works for us before we purchase the license.
Please take a look at this documentation article - How to build in docker.
We’ve modified your docker file, please download.zip (612 Bytes) it and observe the changes.
Document Conversion is working after that modification. The only change is addition of the following lines:
RUN apt-get update && apt-get install -y ffmpeg libgdiplus
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN fc-cache -f -v
We are using an alpine linux image as the base and not debian. The equivalent commands we used are as follows:
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
RUN apk add --no-cache ffmpeg libgdiplus
RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts && fc-cache fc-cache -f
But we don’t have the equivalent for “sed”
RUN sed -i’.bak’ ‘s/$/ contrib/’ /etc/apt/sources.list
Do you think this is sufficient? Please advise. Thank you.
We edited the Docker file with the following configuration the conversion is working:
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS base
WORKDIR /app
EXPOSE 80
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN apk add --no-cache icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
RUN apk add --no-cache ffmpeg libgdiplus
RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts && fc-cache fc-cache -f
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /src
COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"]
RUN dotnet restore "WebApplication1/WebApplication1.csproj"
COPY . .
WORKDIR "/src/WebApplication1"
RUN dotnet build "WebApplication1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebApplication1.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS runtime
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]
Following are the libraries and environment settings which must be added in Docker file:
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN apk add --no-cache icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
RUN apk add --no-cache ffmpeg libgdiplus
RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts && fc-cache fc-cache -f
By the way, we have tested it in Windows nano based docker container. We’re getting null exception. I have attached the docker file. Thank you.Dockerfile_win.zip (406 Bytes)