Automatic rotation of PDF documents using OCR in R

Can anyone give an idea of ​​the automatic rotation of pdf documents. I work in R.
I have documents that have rotation problems and that rotate in all directions.
I need to align them into one and I want to extract information from them.