I would recommend checking out danger zone.
Dangerzone follows a very similar process to this to make a safe pdf from the original
Bellow i have linked a separate discussion which has more details about how Dangerzone works; if you’re interested.
https://discuss.privacyguides.net/t/dangerzone-pdf-sandboxing/15764