How to extract text from a scanned document?
I think your workflow should be something like this:

1) Detect the rectangle.

2) Find the rectangle's orientation.

3) Rotate the rectangle and place it in a new image.

4) Feed the rectangle twice to an OCR 
(one time with the calculated orientation, and the other with the rectangle rotated 180 degrees, because you are not sure if it's oriented correctly).

5) Find which OCR output makes more sense.

6) Voila!

More Details:

1) Check this OpenCV tutorial to detect simple shapes (in your case the rectangle)
http://opencv-code.com/tutorials/detecting-simple-shapes-in-an-image/

2) if you use the previous tutorial, you have the four edges of the rectangle.
calculate the angle between the longest edge and the x-axis.

3) I don't know the level of your image processing skills, but rotating a rectangle's pixels and putting it in another image should be straight forward (I suggest using linear interpolation).

4) I don't have much experience in OCR, but according to many answers here on the exchange, I guess you can use an off-the-shelf OCR.