JSFiddle - React, Tailwind, and code Playground

by jsowl owl

HTML

<label for="Base64StringTxtBox">Base64 String</label>

<textarea id="Base64StringTxtBox" name="Base64Text" rows="4" cols="50">

</textarea>

<button type="Convert" onclick = "downloadAsPDF()" >Convert to PDF</button>

JavaScript

function downloadAsPDF(pdf) {

  var base64String = document.getElementById("Base64StringTxtBox").value;
  const linkSource = base64String;
  const downloadLink = document.createElement("a");
  const fileName = "convertedPDFFile.pdf";
  downloadLink.href = linkSource;
  downloadLink.download = fileName;
  downloadLink.click();
}