Thank you for the response. I've tried solutions suggested in the topic that ou linked and the document isn't corrupetd if I download generated file using ftp but whe I use function
createDoccAndDownload()
automatically downlaoded file gets corrupted. I am aware that it is most likely proble with my server's configuration but are there any suggestions from your side regading this kind of problem? Thanks.