Hi Sami,
I'm not sure if I fully understand you but I guess the Xstring does already contain the PDF document as a binary string.
If this is correct, you will find a detailed tutorial on how to create a download under this link:
http://www.plantogether.de/downloads-in-webui-anwendungen/ I'm afraid I only described it in German language but with the code fragments you should get the point.
Basically, you create a link in your application pointing to the path /sap/webcuif/uif_callback on your server supplying a class implementing interface IF_CRM_WEB_CALLBACK.
In this implementation you create a response with your download data:
* Set filename proposed to the user
ir_server->response->set_header_field(
name = 'Content-Disposition'"#EC NOTEXT
value = 'attachment; filename=umsatz_2013.csv').
* Tell the browser what type of file will be provided
ir_server->response->set_header_field(
name = 'Content-Type'"#EC NOTEXT
value = 'application/pdf' ).
* Provide the content as a Xstring
ir_server->response->set_data( data = lv_content_bin ).
Maybe this helps...
Regards,
Frank