It’s not easy, and depends a lot on how many types of documents you have.
If there are just a few, it actually is easy: you could use CV to extract each type of document, and then detect the type and use one of the CV workflows to extract the data.
But the more document types you have the more work it involves.
If you have a lot of types of documents, the best way is to train a ML model that detects specific fields, no matter the format. That’s what UiPath’s Document Understanding product is doing, it has a ML model that’s been trained on lots and lots of invoices and can extract invoice data.