DinkToPdf on Mac M1

773 Views Asked by At

I have a problem implementing dinkToPdf NuGet Package in my .NET 6.0 WebAPI application. I'm using macbook with M1 chip.

I'm getting the following error:

"Unable to load shared library '/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib, 0x0001): tried: '/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))"

Anyone with the same problem?

1

There are 1 best solutions below

0
Neshat Ajruli On

I managed to find the library for arm64, its located on: https://ports.macports.org/port/wkhtmltopdf/

First install MacPorts for your OS: https://guide.macports.org/chunked/installing.macports.html

Then run this command in terminal: sudo port install wkhtmltopdf

After the installation is complete write in terminal: port contents wkhtmltopdf to check what files are installed by wkhtmltopdf. It will show a list like this:

Port wkhtmltopdf contains:

  /opt/local/bin/wkhtmltoimage
  /opt/local/bin/wkhtmltopdf
  /opt/local/include/wkhtmltox/dllbegin.inc
  /opt/local/include/wkhtmltox/dllend.inc
  /opt/local/include/wkhtmltox/image.h
  /opt/local/include/wkhtmltox/pdf.h
  /opt/local/lib/libwkhtmltox.0.12.3.dylib
  /opt/local/lib/libwkhtmltox.0.12.dylib
  /opt/local/lib/libwkhtmltox.0.dylib
  /opt/local/lib/libwkhtmltox.dylib
  /opt/local/share/man/man1/wkhtmltoimage.1.gz
  /opt/local/share/man/man1/wkhtmltopdf.1.gz

Copy the libwkhtmltox.0.12.3.dylib and rename it to libwkhtmltox.dylib, add the new file on the lib folder inside your project and you are ready to go.