Rename PDF automatically

How it recognises a PDF according to criteria is not a problem. But I want it to recognise the word "invoice number" and the number that follows should be the PDF name.
Example:
xxxxx invoice number 123456 and then rename the file to 123456.pdf.
Is this possible?
Example:
xxxxx invoice number 123456 and then rename the file to 123456.pdf.
Is this possible?