You are calling document.getBinaryBlob() twice; your 2nd call should read textfile.getBinaryStream();
Either "document" or "outStream" is null in that block. You should be able to work out which from the stack trace which gives line numbers.
And in future, please provide more details; it would have been much easier to answer with copy of the stack trace. And please use the code button when you quote code like that; it makes it much easier to read.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com