UnsupportedFormatException in DeclareLibraryMBS

Doing a first test with DeclareLibraryMBS, but so far unsuccessful. Because I can’t print htmlviewer to PDF anymore I need a different solution. I wanted to try WKHtmlToPDF. But in the dylib variation because I need this for MAS.

I extracted the dylib folder and copied it with a copy files step to a new app.

dim f as FolderItem = SpecialFolder.Resources
f = f.Child("lib")
f = f.child("libwkhtmltox.dylib")
Dim d As New DeclareLibraryMBS(f.ShellPath)

f exists and the shellpath is: /Users/beatrixwillius\ 1/Desktop/test.debug.app/Contents/Resources/lib/libwkhtmltox.0.12.6.dylib

However, I get an UnsupportedFormatException in the last code line. What do I need to change to make the code work?

What is in the message property for the exception?

The message is

dlopen(/Users/beatrixwillius\ 1/Desktop/test.debug.app/Contents/Resources/lib/libwkhtmltox.0.12.6.dylib, 10): image not found

Wkhtmltopdf has aliase to the main dylib which is currently libwkhtmltox.0.12.6.dylib. However, using this dylib directly gives the same error.

dylib should be in Frameworks folder.
You may need to use install_name_tool to change the library references to use relative paths. e.g. like this line I recently used for Postgres libraries:

install_name_tool -change “@loader_path/…/lib/libcrypto.1.1.dylib” “@loader_path/libcrypto.1.1.dylib” “/Users/cs/Development/Postgres/Postgres 12.3/Mac/libssl.1.1.dylib”

Thanks, I’ll stick with the original location.

Unfortunately, I don’t understand how to call wkhtmltopdf from your DeclareLibraryMBS at all. Tabling this for now.