The tool [OCRmyPDF](https://github.com/ocrmypdf/OCRmyPDF/tree/main) is a great tool that uses Ghostscript and tesseract to to ocr to pdf files while at the same time it keeps the pdf formatting.