Will this work with several instances of Nextcloud on the same server, but different php-users (php5-fpm)?
I had made a similar setup, but did the ocrmypdf conversion in a separate directory (out of reach of the php5-fpm), and then moved the converted pdf to the respective Nextcloud folder and updated it with the corresponding username.
Your app would have the advantage of simplicity (covering all files) and automation (I have to place the files to convert into a specific directory).