Wkhtml2pdf permission denied and Operation not permitted

I have used wkhtml2pdf on macOS, Windows and Linux for Desktop and Web for years, but now I’m building the app for the MAS, I’m having trouble with wkhtml2pdf in the macOS sandbox.

I embed wkhtml2pdf into my macOS app, but when I run from there it via Shell it is now returning with an ErrorCode 126 Permission Denied.

So I thought I needed to make a copy of wkhtml2pdf into my ApplicationData folder. When I run this copy I get an ErrorCode 126 Operation not permitted. After copying it I use a ‘chmod +x …’ command to ensure it is executable.

Here is my Shell command:
/Users/davidcox/Library/Containers/com.bambamsoftware.bambambilling/Data/Library/Application\ Support/Helpers/local/bin/wkhtmltopdf --page-size A4 --load-error-handling ignore --enable-smart-shrinking --margin-top 10 --margin-bottom 10 --encoding UTF8 --orientation Portrait file:///Users/davidcox/Library/Containers/com.bambamsoftware.bambambilling/Data/Library/Application%20Support/BamBam%20Billing/Downloads/2021-12-16_14-46-29/ReportFile_2021-12-16_14-46-29.html /Users/davidcox/Library/Containers/com.bambamsoftware.bambambilling/Data/Library/Application\ Support/BamBam\ Billing/Downloads/2021\-12\-16_14\-46\-29/BamBam\ Billing\ Export\ 2021\-12\-16\ 14\-46\-29.PDF

And here is the result:
bash: /Users/davidcox/Library/Containers/com.bambamsoftware.bambambilling/Data/Library/Application Support/Helpers/local/bin/wkhtmltopdf: Operation not permitted

How am I supposed to run a ‘foreign’ helper application from within my sandboxed macOS application?

I think it is a Shell vs Terminal issue since this command works fine in Terminal, but fails in Shell:

/Users/davidcox/Desktop/Helpers/local/bin/wkhtmltopdf /Users/davidcox/Desktop/Test.html /Users/davidcox/Desktop/Test.pdf

Any ideas on how to get Shell to run wkhtmltopdf within a macOS Xojo app? It has worked fine for years.

Maybe a privilege level issue?

Maybe you need to use sudo ? (PS I don’t really know what I am talking about- just guessing from things I’ve read in general)


Thanks for the idea, I added a sudo to the front of the command, but it still said Operation not permitted. It seems that Shell is no longer allowed to launch apps in Monterey.

See this link. It may be useful

I think the app must be in your app bundle and signed with same team.
You may check in apples documentation for how to run helper.

1 Like