Hi,
I am trying to convert pdf files into base64 and log them in database. When using read file - "file-in" node and set output to output to base64 and include debug output. Base64 output is generated for the pdf file in debug console. however when we use the output and try to create pdf file using "Base64 to PDF | Base64 Decode | Base64 Converter | Base64" - pdf file is not generated.
when use the website to convert to base64 and use the output to generated pdf file it is working.
any suggestions.
thanks
This assumes that the input is a string, however, PDF is a binary format. Encoding is a translation/representation, not an actual conversion.
Set the file-in node to a 'single buffer object' and run it through a function node with something like:
const base64 = msg.payload.toString("base64")
msg.payload = base64
return msg
The output will be readable as pdf in base64.
To convert it back to a buffer:
const base64_string_input = msg.payload
msg.payload = Buffer.from(base64_string_input, 'base64')
return msg