A possible cause for this is that the stream retrieved from the database contains additional null bytes at its end. Please check if this is the cause on your end and trim the bytes. More information on the issue is available here.
If this does not help, please provide your document so that we can look into the cause of the issue.
I hope this is useful.
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.