Images are not loading when converting HTML to PDF when running from sdk:6.0-alpine Docker container .NET

Images in HTML (img tag with URL) are not rendering in the converted PDF when running inside a sdk:6.0-alpine docker container. The same image is rendering when running from local without a docker container.
Aspose.PDF version: 23.1.0
Code snippet:

    public byte[] ConvertHtmlToPdf(string htmlContent)
{
    using var memoryStream = new MemoryStream();

    HtmlFragment template = new(htmlContent);
    Document document = new();
    document.Pages.Add().Paragraphs.Add(template);
    document.Save(memoryStream);
    return memoryStream.ToArray();
}

I can see the image URL is accessible inside the docker container. What could be the potential reason(s) for not loading the image in the generated PDF?

@sreeraj.thottipparambil.tpr
please provide the ones used:

  • htmlContent value
  • dockerfile

Hello @sergei.shibanov

    HTML: 
      <!DOCTYPE html>

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <div style="border-spacing: 0; border-width: 0; padding: 0;">
    		<h3>Some title</h3>
            <span>https://<our-portal>/sample.png</span>
        </div>
    	
    </body>
    </html>

DockerFile:

ARG CONTAINER_REGISTRY=mcr.microsoft.com
FROM ${CONTAINER_REGISTRY}/dotnet/sdk:6.0-alpine AS publish
WORKDIR /src

ARG CREDENTIALPROVIDER_URL="<>"
RUN curl -H "Accept: application/octet-stream" \
     -s \
     -S \
     -L \
     "${CREDENTIALPROVIDER_URL}" | tar xz -C "$HOME/.nuget/" "plugins/netcore"

........
........

RUN dotnet publish "./eSign/<appname>.csproj" -c Release -o /app/publish \
  --no-restore \
  --runtime alpine-x64 \
  --self-contained true 
  #/p:PublishTrimmed=true \
  #/p:PublishSingleFile=true

FROM ${CONTAINER_REGISTRY}/dotnet/runtime-deps:6.0-alpine AS final

RUN adduser --disabled-password \
  --home /app \
  --gecos '' appuser && chown -R appuser /app

# Remove potential vulnerability
RUN apk upgrade musl

RUN apk add curl
RUN apk --no-cache add libgdiplus
RUN apk --no-cache add msttcorefonts-installer fontconfig && \
    update-ms-fonts && \
    fc-cache -f

.........
.........
COPY eSign/StaticFiles/Aspose.PDF.NET.lic ./eSign/StaticFiles/Aspose.PDF.NET.lics

RUN /usr/sbin/update-ca-certificates

USER appuser
WORKDIR /app
EXPOSE 8080
COPY --chown=appuser:appuser --from=publish /app/publish .

Also note that, I upgraded the Aspose.pDF version to 23.8, still the problem exists.

@sreeraj.thottipparambil.tpr

Have you tried the Aspose.Pdf.Drawing library instead of Aspose.Pdf?
It is more suitable for working with Linux.

I have other tasks as well, like appending text to PDF etc. WIll Aspose.Pdf.Drawing support all of them?

@sreeraj.thottipparambil.tpr
The main disadvantage of Aspose.Pdf.Drawing is that printing is not currently supported. Otherwise, it has the same functionality as Aspose.Pdf.

Great @sergei.shibanov. Its working with Aspose.Pdf.Drawing. Thanks

@sreeraj.thottipparambil.tpr
Thanks for writing the result.
Glad you got it working.