I generate a PDF and get a string like data:application/pdf;base64,JVBERi0xLjMKJf////8K...
.. I save this in a MongoDB.
Now I need to deliver this as a pdf-download to the client. So, I get the entry from the DB and try:
res.writeHead(200, {'Content-Type': 'application/pdf'});
res.end(base64String); // base64String is the data:application/pdf;base64,JVB..-string
This opens a empty pdf in the browser and displays a error:
Error loading the PDF document
how can get this working? Do I need to prepare the base64String in some way before sending it to the client?