Converting base64 string to PDF and saving it in a folder on desktop

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question:
How do convert a base64 string from a response and convert it to pdf and store/save it to a folder ? I’ve managed to store the string in a variable in Postman.

Details (like screenshots):
I’ve tried this code in Test tab from base64guru.com

// The Base64 string of a simple PDF file
var b64 = ‘base64 encoding’;

// Decode Base64 to binary and show some information about the PDF file (note that I skipped all checks)
var bin = atob(b64);
console.log(‘File Size:’, Math.round(bin.length / 1024), ‘KB’);
console.log(‘PDF Version:’, bin.match(/^.PDF-([0-9.]+)/)[1]);
console.log(‘Create Date:’, bin.match(/xmp:CreateDate(.+?)</xmp:CreateDate>/)[1]);
console.log(‘Modify Date:’, bin.match(/xmp:ModifyDate(.+?)</xmp:ModifyDate>/)[1]);
console.log(‘Creator Tool:’, bin.match(/xmp:CreatorTool(.+?)</xmp:CreatorTool>/)[1]);

// Embed the PDF into the HTML page and show it to the user
var obj = document.createElement(‘object’);
obj.style.width = ‘100%’;
obj.style.height = ‘842pt’;
obj.type = ‘application/pdf’;
obj.data = ‘data:application/pdf;base64,’ + b64;
document.body.appendChild(obj);

// Insert a link that allows the user to download the PDF file
var link = document.createElement(‘a’);
link.innerHTML = ‘Download PDF file’;
link.download = ‘file.pdf’;
link.href = ‘data:application/octet-stream;base64,’ + b64;
document.body.appendChild(link);

How I found the problem:
I’ve pasted the string in the code and tried to execute.
There’s an error in console:
“ReferenceError: document is not defined”

I’ve already tried: