Hello.
Thank you for using Apple Support Communities. It sounds like you're experiencing issues with your photos coming out upside down. If so, we'd like to look into this with you.
You had mentioned that this issue is occurring when photographing documents. Does it also occur when taking regular photos? Which iPhone model and iOS version are you currently using?
Identify your iPhone model
Find the software version on your iPhone, iPad, or iPod
If you force close the Camera app and restart your iPhone, does this specific issue continue to occur?
How to force an app to close on your iPhone, iPad, or iPod touch
Restart your iPhone
Feel free to update us. Cheers.