I want to convert a PDF file into its Base64 version. Everything I1ve found in my internet research involves promisses, async functions and DOM manipulation, which is not supported by Studio Pro (as far as I know). Usually you need to create an HTML page with an input of type file and an id. Then you use getElementById() to get the file, create an async function that converts the file into Base64.
But I’m working with local files and I need to convert them without uploading them anywhere. I’ve tried using btoa() but Studio Pro throws and error sayong Variable 'btoa' is not defined, which is weird because it’s not supposed to be a variable.
Apparently, it has to be run using PowerShell. I want it to run in the background, so I tried running the command in the prompt by typing PowerShell, then ENTER, then trying the command above again. It works just fine when I run it manually, but not when I use the Command Prompt activity.
Thank you. Your suggestion works, but I’ve just realized that it’s not what I need.
The file cannot be decoded back into a PDF file, probably because I’m using the Read Text activity. So it encodes the text into base64. What I actually need is to encode the PDF file into base64.
You can set up 2 variables called pdfPath (path of the file you want to convert to base64) and outputPath (file where the resulting base64 code will be saved), and then use the following command inside the Command Prompt activity (with “Calculate a value” selected):