refactor generateDocument(InputStream) method if inputstream is null