Thanks Studio 42.
I will try to use .htaccess directives instead of PHP custom code to redirect the unwanted Google links. On the other hand, I still can't find a way to stop Google indexing the PDF orders. This store uses Cloudflare CDN for caching. Could it be the origin of the problem?
Best regards.