Here's an API that looks promising.
"CamScanner API enables your application to automatically detect page borders and smartly remove background. Enhance your image with up to five modes to make the contents clearer and more readable. Return processed documents to your app in JPG or PDF format."
https://dev.camscanner.com/?language=en-us