We are exploring aspose.pdf for .Net library to achieve our requirement. While are containerize the same application with linux it is not working properly. it seems to be an fonts issues. the main concern here is that we have to containerize the .net application in linux environment. ones we could be able to resolve the issue then we can go ahead and purchase license of the product. Can you please guide how we can resolve the issue. I am attaching .net core solution here with the ticket for your reference.
you can also find dockerfile within the same solution as well.
@vbhattsynoptek
Thank you for preparing and attaching the project.
It started up in my environment (attached a screenshot, launched Docker Compose) Docker Compose.png (57.6 KB) screen.png (47.7 KB)
If we assume that the docker should work uniformly, we can assume that the matter is in the environment.
Is it firewall blocking possible?
We have checked from our end as well by reinstalling docker and wsl.exe as well but we are facing same issue. We have also consulted with IT Team and they have confirmed that there are no any blocker from firewall end. We would like to ask below question which may help us to make progress on this ticket.
Which docker version you are using? W are using docker desktop 4.19.0.
2.Which operating system you are running the solution. - we are using windows 11 pro.
3.Which aspose version you have used from your end.We are using 23.4.0.
@vbhattsynoptek
I have Windows 10 Pro (22H2) installed.
I’m using Docker Desktop version 4.17.0 (running it as administrator). When opening the attached project, I only added the directory to File sharing. And accordingly, the version of the package is the same as in the attached project 23.4 Docker Desktop.png (52.2 KB)
Thanks for quick response. We have check the version which you have shared but it is not working in out machine.
We did some R&D and go through couple of solutions, based on it we have added few lines in docker file and it working now.
Addres below lines:
RUN apt-get update && apt-get install -y libgdiplus
RUN sed -i’.bak’ ‘s/$/ contrib/’ /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so
RUN apt update
RUN apt install -y libgdiplus
RUN ln -s /usr/lib/libgdiplus.so /lib/x86_64-linux-gnu/libgdiplus.so
We are just querious that how it is working in your machine. It would be really helpfull for us to troubleshoot the same.
@vbhattsynoptek
By the way, for Linux it’s probably best to use a library Aspose.Pdf.Drawing.
It does not require libgdiplus.
It can be assumed that this is due to the difference in the environments.
I have Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.5.
Perhaps influenced by what is installed in Visual Studio.
Related to aspose.pdf.drawing so we have included in our application but it was still throwing gidplib related runtime exception. to resolve the same we have added gidlib related code into the dockerfile.
We have confirm that we have also VS 2022 and 17.5.5 addition to that we have not install any additional package into that.
Just shared updated demo example prepared from our end. just want to know is it correct way to resolve the issue and is it possible to run application successfully in docker with linux environment without adding addional fonts and gidp library? - asking as you have mentioned earlier, the demo is working in your machine without additional code in docker file which is strange behevior for us .
the difference is just a docker version as we are using latest version of docker for windows and running application in linux container. please suggest.
I added packages (to the standard VS installation) and maybe that’s why we have a difference.
Aspose.Pdf.Drawing is an alternative to the Aspose.Pdf package.
And you should use one of these packages (in the attached project, they are both connected). Aspose.Pdf uses the Gdi library, while Aspose.Pdf.Drawing uses the Aspose.Drawing library.
Accordingly, there are fewer problems when in Linux using Aspose.Pdf.Drawing, especially if you install standard Microsoft fonts.
The main limitation at the moment is the lack of a Printing API.
The project attached in the last post running in my environment without any changes on my part.
Than I removed the Aspose.Pdf library from the project and removed the lines (#4,8) related to gdiplus in the dockerfile. DockerFileScreen.png (37.6 KB)
And so the project running
.
On any HTML assets, images, files that are needed by the PDF copy them to output directory and make sure they are referenced properly by anything that needs them through absolute path or relative if it makes sense.
Our .net application starts up from within the shell file using
./ApplicationName --ENVIRONMENT=Test
Our Dockerfile Example:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
RUN apt update
RUN apt install -y unixodbc-dev
# Copy everything
COPY . ./
RUN dotnet publish ApplicationTest.sln -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 80
COPY --from=build-env /app/out .
ENTRYPOINT ["bash","startupshellscript.sh"]
WORKDIR /app
Should it be in the ch file?
If I just include this part to existing dockerfile instead of ENTRYPOINT ["bash","startupshellscript.sh"]
will be the same result?
@usmanpop
Maybe it’s better for you to create a project with all the settings and files you want and attach it to be sure that everything is exactly the way you want it to be.
Only in the project should the reference to Aspose.Pdf.Drawing be removed (leaving only Aspose.Pdf).
And for better use in Linux Aspose.Pdf.Drawing, then you don’t need to install gdiplus.