skip to Main Content

I’m trying to generate PDFs from HTML using DinkToPdf library with docker, but i can’t get that showing the image from docker container running, while debugging from windows I have no problems:

enter image description here

I have added many libraries to my dockerfile that i have seen in others topics, but i have not been successful. My dockerfile is as follows:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . .
WORKDIR /src/WebApi
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1    
RUN apt-get update && apt-get install -y libgdiplus 
        ca-certificates 
        xvfb 
        libfontconfig 
        wkhtmltopdf 
        fontconfig 
        zlib1g 
        fontconfig 
        libfreetype6 
        libx11-6 
        libxext6 
        libxrender1 
        libjpeg62-turbo 
        libxcb1 
        xfonts-75dpi 
        xfonts-base 
        openssl 
        wget 
        gdebi
WORKDIR /app
COPY --from=build /src/WebApi/out ./
ENTRYPOINT ["dotnet", "WebApi.dll"]

Any idea what library I need to add to the dockerfile to show the images?

PS: My html code:

<table class='tbl' cellpadding='5'>
    <tbody>
        <tr>
            <td class='tbl-img'>
                <img src='https://pngimg.com/uploads/batman/batman_PNG75.png' alt='' height='51' width='200' />
            </td>
        </tr>
        <tr>
            <td class='tbl-title'>THIS IS THE TITLE OF THE DOCUMENT</td>
        </tr>
        <tr>
            <td class='tbl-subtitle'>THIS IS THE SUBTITLE OF THE DOCUMENT</td>
        </tr>
    </tbody>
</table>

2

Answers


  1. Chosen as BEST ANSWER

    The solution for this issue was added on github: github.com/rdvojmoc/DinkToPdf/issues/159


  2. The solution as specified in not the solution, at all. I tried with base64 string of the image and dinktopdf is showing the image well locally but on deployment to linux server, the image is not shown.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search