Hi Akriti,
In the Idoc generation program use the base64 encoding and while creating the PDF or TXT file use base64 decoding, then you should not face the issue.
Please find an example below:
DATA: z TYPE string,
encode TYPE string,
decode TYPE string .
DATA: obj TYPE REF TO cl_http_utility,
cref TYPE REF TO if_http_utility.
CREATE OBJECT : obj.
cref = obj.
z = 'what u have to encode'.
encode = obj->if_http_utility~encode_base64( z ) .
decode = obj->if_http_utility~decode_base64( encode ).
Regards,
Rachit.