data:application/pdf;base64,JVBERi0xLjEKJcKlwrHDqwoKMSAwIG9iagogIDw8IC9UeXBlIC9DYXRhbG9nCiAgICAgL1BhZ2VzIDIgMCBSCiAgPj4KZW5kb2JqCgoyIDAgb2JqCiAgPDwgL1R5cGUgL1BhZ2VzCiAgICAgL0tpZHMgWzMgMCBSXQogICAgIC9Db3VudCAxCiAgICAgL01lZGlhQm94IFswIDAgMzAwIDE0NF0KICA+PgplbmRvYmoKCjMgMCBvYmoKICA8PCAgL1R5cGUgL1BhZ2UKICAgICAgL1BhcmVudCAyIDAgUgogICAgICAvUmVzb3VyY2VzCiAgICAgICA8PCAvRm9udAogICAgICAgICAgIDw8IC9GMQogICAgICAgICAgICAgICA8PCAvVHlwZSAvRm9udAogICAgICAgICAgICAgICAgICAvU3VidHlwZSAvVHlwZTEKICAgICAgICAgICAgICAgICAgL0Jhc2VGb250IC9UaW1lcy1Sb21hbgogICAgICAgICAgICAgICA+PgogICAgICAgICAgID4+CiAgICAgICA+PgogICAgICAvQ29udGVudHMgNCAwIFIKICA+PgplbmRvYmoKCjQgMCBvYmoKICA8PCAvTGVuZ3RoIDU1ID4+CnN0cmVhbQogIEJUCiAgICAvRjEgMTggVGYKICAgIDAgMCBUZAogICAgKEhlbGxvIFdvcmxkKSBUagogIEVUCmVuZHN0cmVhbQplbmRvYmoKCnhyZWYKMCA1CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAxOCAwMDAwMCBuIAowMDAwMDAwMDc3IDAwMDAwIG4gCjAwMDAwMDAxNzggMDAwMDAgbiAKMDAwMDAwMDQ1NyAwMDAwMCBuIAp0cmFpbGVyCiAgPDwgIC9Sb290IDEgMCBSCiAgICAgIC9TaXplIDUKICA+PgpzdGFydHhyZWYKNTY1CiUlRU9GCg==
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support & Fixpack team lead
IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
https://stamm-wilbrandt.de/en/blog/
------------------------------
Original Message:
Sent: Thu July 27, 2023 03:52 AM
From: Marwan Hesham
Subject: IBM Data Power decoding issue
Thanks a lot, I have tried it but I have another question how can I create a pdf and then attached it to the response message, and in what format (for example utf-8, hex )do I need to create a pdf cause I have tried this code but the pdf isn't correct
let crlf = '\r\n';
// your boundry is a string starts with _Part and then some numbers
let multipartMessageStartPart = '------=your boundry' + crlf +
'Content-Type: application/json; charset=UTF-8' + crlf +
'Content-Transfer-Encoding: 8bit' + crlf + crlf +
'{\n"header": {\n"status": {\n"code": "200",\n"description": "success"\n}\n}' + crlf +
'------=your boundry' + crlf +
'Content-Type: application/pdf; name=text.pdf' + crlf +
'Content-Transfer-Encoding: binary' + crlf +
'Content-ID: <text.pdf>' + crlf +
'Content-Disposition: attachment; name="text.pdf"; filename="text.pdf"' + crlf + crlf;
let multipartMessageEndPart = crlf + crlf + '------=your boundry';
let base64 = 'base64 text value for the encoded pdf';
let buff = Buffer.from(base64, 'base64').toString();
session.output.write(multipartMessageStartPart + buff + multipartMessageEndPart);
var contentType = 'multipart/related; boundary="----=your boundry"; type="application/json"';
------------------------------
Marwan Hesham
Original Message:
Sent: Thu July 27, 2023 02:30 AM
From: Hermann Stamm-Wilbrandt
Subject: IBM Data Power decoding issue
Hi, "Buffer" is the GatewayScript datatype for data up to 1GB size.
Use ".from(str, 'base64')" to do the conversion you want:
buffer object
Short demo with node in Linux shell:
$ str=`echo -n "foobar" | base64`
$ node -e "console.log(Buffer.from('$str', 'base64'))"
<Buffer 66 6f 6f 62 61 72>
$
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support
IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
https://stamm-wilbrandt.de/en/blog/
Original Message:
Sent: Wed July 26, 2023 03:55 AM
From: Marwan Hesham
Subject: IBM Data Power decoding issue
Hello Team, I wanted to make a data power service that receives a base64 string and then converts this string into a pdf file and sends it back as an attached File, The problem is when I used xslt dp:decode to decode the base64 string it gives an error because it contains non-UTF-8 characters so what to do I tried to look for any javascript build function that is supported in IBM data power gateway but can't find any so what to do and what is the best scenario for this service to work and also how to use multipart with the pdf so that it could be sent as an attached file?
------------------------------
Marwan Hesham
------------------------------