Comments (29)
@fernandovictorTI, I believe the problem is that the second stage of your build (runtime
) is not running the below command again, so libwkhtmltox
and it's dependencies are left in the first stage (build
).
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
from dinktopdf.
I deployed my application on Linux and it works. But I installed libgdiplus as I needed it in Captcha component which I use in my application. I don't know if wkhtmltopdf depends on it or not.
Try to install it. Hope this fix your problem.
sudo apt-get install libgdiplus
from dinktopdf.
After install of libgdiplus in microsoft/dotnet:1.1.2-runtime
image libwkhtmltox library is found.
Dockerfile:
FROM microsoft/dotnet:1.1.2-runtime
RUN ["apt-get", "update"]
RUN ["apt-get", "-y", "install", "libgdiplus"]
WORKDIR /app
COPY / .
ENTRYPOINT ["dotnet", "DinkToPfd.TestConsoleApp.dll"]
Result:
636370886662487690.pdf
Thanks @Ahmed-Raouf for pointing this out.
from dinktopdf.
In case someone else runs into this problem when running tests (inside a Docker container or in a Linux host), adding libgdiplus
to the image didn't do the trick for me.
I checked libwkhtmltox.so
with ldd
and libgdiplus
is not found as a dependency:
# ldd libwkhtmltox.so
linux-vdso.so.1 (0x00007ffc29de1000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f628c25d000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f628c01f000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f628bd70000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f628bb5e000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f628b81e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f628b604000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f628b400000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f628b1f8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f628afdb000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f628ac59000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f628a955000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f628a73e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f628a39f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f628f1a2000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f628a175000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f6289f42000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f6289d1a000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f6289b16000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f6289910000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f62896fa000)
What worked for me, for running tests, was to copy libwkhtmltox.so
to /usr/lib
directory.
from dinktopdf.
After 4 days it worked.
Thank you
from dinktopdf.
And how do you using it in the code? I am running .NET Core 2.0 and i registered converter as:
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
and i am using it as _converter.Convert(MyDoc), injected as IConverter from constructor.
I tried to install all the suggestions from your comments, still unable to load dll in docker container.
Dockerfile:
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY MyProj/MyProj.csproj MyProj/
RUN dotnet restore MyProj/MyProj.csproj
COPY . .
WORKDIR /src/MyProj
RUN dotnet build MyProj.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish MyProj.csproj -c Release -o /app
FROM base AS final
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyProj.dll"]
UPDATE:
This actually works, so just use this way instead registering and adding DLL manually, as i tried before this post. Hope this helps someone...
from dinktopdf.
Hi @fernandovictorTI, here's the RUN command I used:
# Download libwkhtmltox and install it's dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
Results may vary depending on the source image you're using. In my case I'm using microsoft/dotnet:2.0-sdk-stretch
.
from dinktopdf.
@fernandovictorTI, I believe the problem is that the second stage of your build (
runtime
) is not running the below command again, solibwkhtmltox
and it's dependencies are left in the first stage (build
).RUN apt-get update \ && apt-get install -y --no-install-recommends \ zlib1g \ fontconfig \ libfreetype6 \ libx11-6 \ libxext6 \ libxrender1 \ && curl -o /usr/lib/libwkhtmltox.so \ --location \ https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
this helped to me
from dinktopdf.
@miguelalvarezi
Thank you for your help, I just forgot to answer that it is ok and it works.
Currently, requirenmets for pdf files were changed (need to support different headers for pages) and now I use .net core node services and nodejs html-pdf utility. I was wonder how fast it works.
from dinktopdf.
Hi,
I tried to run example DinkToPdf.TestConsoleApp on Ubuntu 16.04 LTS without problems.
Make sure that libwkhtmltox.so is placed in root folder (where your main project .dll is) of your project and is named correctly (libwkhtmltox).
from dinktopdf.
Try to add the files:
libwkhtmltox.dll
libwkhtmltox.dylib
libwkhtmltox.so
on the root folder.
from dinktopdf.
@fernandovictorTI, if you can share your Dockerfile I can review it and maybe give you some guidance.
from dinktopdf.
For those still researching, my problem was that I was including all 3 libraries (.dll / .so / .dylib) in my .Net Core 5 WebAPI distributable on the AWS EC2 instance. Deleting 2 of them, just leaving the .so, and installing wkpdftohtml on the instance, solved the problem.
from dinktopdf.
Any update?
from dinktopdf.
I have tried it again. I should add that I am trying it on the microsoft/dotnet:1.1.2-runtime
image. So that might complicate things also. Have you tried using the library in that way?
from dinktopdf.
Is it possible to share your image? I never tested it in that way, but will happily take a look into it.
from dinktopdf.
If you are running on Linux copying libwkhtmltox.so is enough.
from dinktopdf.
I added libgdiplus to the image and it works! Thanks for the help :-)
from dinktopdf.
Hi @miguelalvarezi
How do I copy libwkhtmltox.so to /usr/lib in DockerFile?
from dinktopdf.
Hi @miguelalvarezi,
I´m using microsoft/aspnetcore-build:2.0.
I turned his command on, but continued with error.
run cd /usr/lib && ls
2018-05-15T19:59:14.5356050Z apt
2018-05-15T19:59:14.5375180Z binfmt.d
2018-05-15T19:59:14.5391880Z coreutils
2018-05-15T19:59:14.5406080Z dpkg
2018-05-15T19:59:14.5421160Z gcc
2018-05-15T19:59:14.5435550Z gnupg
2018-05-15T19:59:14.5449470Z locale
2018-05-15T19:59:14.5464690Z mime
2018-05-15T19:59:14.5481610Z modules-load.d
2018-05-15T19:59:14.5495690Z os-release
2018-05-15T19:59:14.5509430Z perl5
2018-05-15T19:59:14.5523650Z python2.7
2018-05-15T19:59:14.5537710Z python3
2018-05-15T19:59:14.5552810Z sasl2
2018-05-15T19:59:14.5566130Z ssl
2018-05-15T19:59:14.5581820Z sysctl.d
2018-05-15T19:59:14.5596730Z systemd
2018-05-15T19:59:14.5611020Z tar
2018-05-15T19:59:14.5624310Z tc
2018-05-15T19:59:14.5638380Z tmpfiles.d
2018-05-15T19:59:14.5652160Z x86_64-linux-gnu
It was to have the packages that I had installed?
from dinktopdf.
#########1º Passo (Restore/Build/Publish)
FROM microsoft/aspnetcore-build:2.0 AS build
ARG CONFIGURATION
COPY . /src
WORKDIR /src
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
libgdiplus \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
#
RUN cd /usr/lib
RUN ln -s libgdiplus.so gdiplus.dll
#
RUN dotnet restore PJMT.EmissaoCertidaoNegativa.sln --no-cache && \
dotnet build ./src/PJMT.Aurora.API -c $CONFIGURATION -o /app && \
dotnet publish ./src/PJMT.Aurora.API -c $CONFIGURATION -o /app
#########2º Passo (runtime)
FROM nexusdocker.tjmt.jus.br/dsa/dotnetcore:latest as runtime
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT dotnet PJMT.EmissaoCertidaoNegativa.API.dll
run cd /usr/lib && ls
run cd /usr && ls
from dinktopdf.
Still giving the error.
{
"error": {
"message": "Unable to load DLL 'libwkhtmltox': The specified module or one of its dependencies could not be found. \ n (Exception from HRESULT: 0x8007007E)",
"exception": "DllNotFoundException"
}
}
from dinktopdf.
Guys, I faced with the same issue. Can't load library on Linux docker image.
I've an .Net Core 2.0 API project and I add a docker support via Visual Studio. Then, I added libwkhtmltox library and it's dependencies to the image.
Currently, my dockerfile looks like
FROM microsoft/aspnetcore:2.0 AS base
# Install libwkhtmltox dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY API/API.csproj API/
RUN dotnet restore API/API.csproj
COPY . .
WORKDIR /src/API
RUN dotnet build API.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish API.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "API.dll"]
I placed the library files to /app/wkhtmltox folder. Also, thanks to #5 I can run the project from Visual Studio on Windows.
But, docker fails. I tried to use /app/wkhtmltox/libwkhtmltox path and also tried /usr/lib/libwkhtmltox and I still get the error " System.DllNotFoundException: Unable to load DLL '/app/wkhtmltox/libwkhtmltox': The specified module or one of its dependencies could not be found."
Could you please help to figure out with that?
Thanks.
from dinktopdf.
@DmitriyZaporozhets, conceptually the same problem @fernandovictorTI had, each new build stage can only get artifacts from the previous stages. More information here.
You should put the RUN step which installs libwkhtmltox
and it's dependencies in each build stage that will need it. In your case I'd guess it would only be the last one, final
.
from dinktopdf.
@miguelalvarezi
Thank you for your response.
Actually, installing dependencies only in the final was my first idea. And unfortunately it does not work for me.
As I understand, you mean this one should work. I provide only last, final image
FROM base AS final
# Install libwkhtmltox dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
libxrender1 \
&& curl -o /usr/lib/libwkhtmltox.so \
--location \
https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "API.dll"]
The application tries to load the library from '/app/wkhtmltox/libwkhtmltox', but fails.
from dinktopdf.
@DmitriyZaporozhets, the library is being downloaded by curl
to /usr/lib/libwkhtmltox.so
, so the application will never find it in /app/wkhtmltox/libwkhtmltox
from dinktopdf.
Hi,
I tried to run example DinkToPdf.TestConsoleApp on Ubuntu 16.04 LTS without problems.
Make sure that libwkhtmltox.so is placed in root folder (where your main project .dll is) of your project and is named correctly (libwkhtmltox).
Hi, I am using Ubuntu 18.04 LTS.
Copied the library libwkhtmltox in the root folder of the MAIN project.
In the image you can see that it is found there.
libgdiplus is already the newest version (4.2-2).
0 upgraded, 0 newly installed, 0 to remove and 235 not upgraded.
Any idea ?
from dinktopdf.
Para aqueles que ainda estão pesquisando, meu problema era que eu estava incluindo todas as 3 bibliotecas (.dll / .so / .dylib) em meu .Net Core 5 WebAPI distribuível na instância AWS EC2. Excluir 2 deles, apenas deixando o .so, e instalando wkpdftohtml na instância, resolveu o problema.
can you show me?
from dinktopdf.
Unable to load DLL 'libwkhtmltox'
I didn't have some of the dependencies:
linux-vdso.so.1 (0x00007ffcfd39c000)
libXrender.so.1 => not found
libfontconfig.so.1 => not found
libfreetype.so.6 => not found
libXext.so.6 => not found
libX11.so.6 => not found
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0bbe6d8000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0bbe6d2000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0bbe6c8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0bbe6a6000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0bbe4d9000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0bbe395000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0bbe379000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0bbe1a5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0bc1436000)
I installed all lacking dependencies with a command
apt-get update && apt-get install -y --allow-unauthenticated apt-utils libc6-dev libxrender1 libfontconfig1 libgdiplus libjpeg62-turbo libfontconfig1 libfreetype6 libxext6 libx11-6 fontconfig zlib1g
and everything started working.
from dinktopdf.
Related Issues (20)
- bootstrap format in html partial view HOT 1
- Not able to convert math related symbols
- It is possible to use html footer with page number ?
- nodejs : Depends: libc6 (>= 2.28) but 2.24-11+deb9u4 is to be installed
- css flex not working HOT 4
- I can't generate on a second request HOT 3
- Erro docker linux HOT 2
- Including image in the footer
- HTML tags removed HOT 1
- libwkhtmltox.dylib for mac M1 chip HOT 1
- One or more errors occurred. (Unable to load shared library 'libwkhtmltox' or one of its dependencies HOT 3
- Can't convert Page url to Pdf on Linux HOT 2
- How can I add background-image?
- Footer not working when there is an image
- Docker Image Error on arm64 Linux EC2 Instance HOT 2
- Outline of globalsetting is not working
- library not loading correctly
- StopThread() cannot stop the newly opened background thread, resulting in unlimited thread growth and eventually breaking the Linux system limit.
- Still maintaned? HOT 1
- It's not compatible with .net 8.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dinktopdf.