Trying to download a PDF file using Velo code
Wix Editor
Im trying to add a download feature for my website with velo code…i tried running sample test code which downloads a test pdf. But no file is being downloaded…This is the code…
///
import { saveAs } from “file-saver”;
import { jsPDF } from ‘jspdf’;
$w.onReady(function () {
$w(“#testDownloadButton”).onClick(() => {
const doc = new jsPDF();
doc.text(“Hello, this is a test PDF”, 10, 10);
const pdfBlob = doc.output(“blob”);
// Log for debugging
console.log("PDF Blob created, now triggering saveAs");
saveAs(pdfBlob, "test.pdf");
console.log("FileSaver save triggered");
});
});