How to get filestream from javascript code

I have an thrid-party javaScript which can handle image process, like combine image, conver to pdf etc, and result in one image or pdf file。
Now I need to add it to cuba project, how to get the result pdf/image from the javascript code?
I used to call javascript function in cuba, but not sure how to get result image/pdf stream from javascript code. I am using cuba6.10.

Hello @anjingjing

Could you clarify what library do you use?