October 25, 2024
Chicago 12, Melborne City, USA
jQuery

Need To Save A HTML2PDF PDF Without Backend Code


I have a static HTML site using Bootstrap 4, JQuery and HTML2PDF.

On submit I have a button which when clicked displays my HTML2PDF PDF using the blow code

let page = document.getElementById('cloa_pdf');
let pdfName = document.getElementById('company-name').value

pdfName = pdfName.replace(/ /g,"_")

const opt = {
    margin:       .25,
    filename:     pdfName + '_' + date + '_CLoA.pdf',
    html2canvas:  { scale: 2 },
    jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait' }
};

html2pdf().set(opt).from(page).save();

I have been asked to automatically save the PDF to a file in the project folder but the only solutions I can find require a backend (PHP, C#) which the site doesn’t have so I need to do client side

This is my folder structure

enter image description here

I want them to be saved in the ‘PDF’ folder WITHOUT backend code

Just to point I am a newbie to HTML2PDF and have looked on the HTML2PDF site and cant find a solution either.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video