Is there a libarary or SDK which is capable of this?
I want to take a picture of a existing document and then with use of the library/SDK it should line it straight, even when the document is taken under an angle.
I don't need necessary the text of the document. I just need a scan from the document. If it is slanted then it should adjust and send it like a PDF.
The last step (sending) is the easiest.
If the picture is not only XY-rotated but also taken from an angle that is not perpendicular to the document planar surface, there will also be some perspective deformation.
As Erel said, Opencv can be used to detect the contours, then the edges, and 'undo' this XY-rotation and perspective using homography.
Some programming is involved, and reliability will depend on image quality (homogeneus background, avoiding other objects in the picture,...among others)